Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to write properties in design time

How to write properties in design time

Scheduled Pinned Locked Moved C#
tutorialquestiongraphicsdesign
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ElCachubrey
    wrote on last edited by
    #1

    Hi all I have an inherited control from standard textbox control. In this textbox control i set some default property value to new one. //Suppose i want what derived control has by default BackColor = Red; this.BackColor = System.Drawing.Color.Red; In this case when user place my derived control to a form designer generate in InitializeComponent() this rows ((System.ComponentModel.ISupportInitialize)(this.derivedTextBox)).BeginInit(); .... this.derivedTextBox.BackColor = System.Drawing.Color.Red; As a result when form are created DerivedTextBox.BackColor property invoked 2 times. First - when control created and Second - in the InitializeComponent() method of form where placed. I know that in this example it dosn't matter but actually i have other base control (not text box), what can add to oneself buttons [for examp: this.Buttons.Add("MyNewButton") - base control by default not have this button, but in derived it shoul be], and since what every time when i want to add button to this control one add two times) And now i have question, is exists an event what invoked only when control added to a form??? Or where in code i should write initialization control code so as this code will only generated in InitializeComponent() method of form and not to bee invoked when control are created???? THANK.

    X 1 Reply Last reply
    0
    • E ElCachubrey

      Hi all I have an inherited control from standard textbox control. In this textbox control i set some default property value to new one. //Suppose i want what derived control has by default BackColor = Red; this.BackColor = System.Drawing.Color.Red; In this case when user place my derived control to a form designer generate in InitializeComponent() this rows ((System.ComponentModel.ISupportInitialize)(this.derivedTextBox)).BeginInit(); .... this.derivedTextBox.BackColor = System.Drawing.Color.Red; As a result when form are created DerivedTextBox.BackColor property invoked 2 times. First - when control created and Second - in the InitializeComponent() method of form where placed. I know that in this example it dosn't matter but actually i have other base control (not text box), what can add to oneself buttons [for examp: this.Buttons.Add("MyNewButton") - base control by default not have this button, but in derived it shoul be], and since what every time when i want to add button to this control one add two times) And now i have question, is exists an event what invoked only when control added to a form??? Or where in code i should write initialization control code so as this code will only generated in InitializeComponent() method of form and not to bee invoked when control are created???? THANK.

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      if you have a constructor in your derived class then inherit the base class constructor, like:

      MyTextBox(): base()
      {

          }
      

      i think you should use ControlAdded Event

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups