c# - add behavior to group of windows form controls -


I am trying to copy the web functionality of a label on the text box which will be included in the text box Shows the type of I can add events individually but I am thinking that there is a way to add 'behavior' to the set of controls.

Please see example code:

  Private Zero label first name (link), object sender, EventErgus e) {HideLabelFocusTextBox (labelFirst name, textbox first name); } Private Zero HideLabelFocusTextBox (label labelTohehide, text box textboxes) {LabelToHide.Visible = false; TextBoxToShow.Focus (); } Private Zero TextBoxFirstName _Love (Object Sender, EventArgse E) {if (string.isnororappletyte (Text TextFastName Text)) LabelFirstName Visual = true; } Private Zero TextBoxFirstNameInter (Object Sender, EventAgds E) {labelFirstName.Visible = false; }  "post-text" itemprop = "text"> 

You can sub-class to control the text box (type your own text box) < P> BTW, I have thought about it and I will take another approach:

I will override the paint handler of the text box and when there is no information in the text box, drag an information string in it .

Something like this:

 using the  system; Using System.Windows.Forms; Using System.Drawing; Class MyTextBox: Textbox {Public MyTextBox () {SetStyle (ControlStyles.UserPaint, true); } Secure Override Zero OnPaint (PaintEventArgs E) {If (string.IsNullOrEmpty (this.Text)) {e.Graphics.DrawString ("My Information String ...", this.Font, System.Downings.brush.gray, New System.Drawing.PointF (0, 0)); } Other {E. Graphics.Drustring (text, this.font, new solidbrush (this for the collar), new system, drawing.POFF (0, 0)); }} Safe Override Zero On-Test Extended (EventArgs e) {Invalid (); Base.OnTextChanged (E); }}  

Comments