C # recursively iterates through the form all TextBox controls, and then sets the TextBox event

Source: Internet
Author: User

1 /// <summary>2         /// 3         /// </summary>4         /// <param name= "Sender" ></param>5         /// <param name= "E" ></param>6          Public Virtual voidSettextboxonenterstyle (Objectsender, EventArgs e)7         {8             if(Sender isTextBox)9             {TenTextBox Tbox = Sender asTextBox; One                 if(!Tbox. ReadOnly) A                 { -Tbox. BackColor =Color.yellow; -                 } the             } -         } -  -         /// <summary> +         ///  -         /// </summary> +         /// <param name= "Sender" ></param> A         /// <param name= "E" ></param> at          Public Virtual voidSettextboxonleavestyle (Objectsender, EventArgs e) -         { -             if(Sender isTextBox) -             { -TextBox Tbox = Sender asTextBox; -                 if(!Tbox. ReadOnly) in                 { -Tbox. BackColor =Color.White; to                 } +             } -         } the /// <summary> *         ///  $         /// </summary>Panax Notoginseng         /// <param name= "frm" ></param> -          Public Virtual voidsetformtextboxcontrolstyle (Form frm) the         { + Iteratecontrolssettextbox (frm. Controls); A         } the  +         /// <summary> -         ///  $         /// </summary> $         /// <param name= "CTLs" ></param> -          Public Virtual voidIteratecontrolssettextbox (control.controlcollection CTLs) -         { the             foreach(Control controlinchCTLs) -             {Wuyi                 if(Control isTextBox) the                 { -(Control asTextBox). Enter + =NewEventHandler (settextboxonenterstyle); Wu(Control asTextBox). Leave + =NewEventHandler (settextboxonleavestyle); -                 } About  $                 if(Control. Controls.Count >0) -                 { - Iteratecontrolssettextbox (Control. Controls); -                 } A             } +         } the     
View Code

C # recursively iterates through the form all TextBox controls, and then sets the TextBox event

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.