Click here to Skip to main content
15,892,298 members
Articles / Programming Languages / C# 4.0
Alternative
Tip/Trick

How to clear a Multiple TextBox values in a single click in C# .NET

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
2 Oct 2011CPOL 6K  
We can better have an extension like: public static class ControlExtension { public static IList FindControlByName(this Control control) where T : Control { List controlsFound = new List(); controlsFound.AddRange(control.Controls.OfType()); ...
We can better have an extension like:

C#
public static class ControlExtension
 {
   public static IList<t> FindControlByName<t>(this Control control) where T : Control
   {
     List<t> controlsFound = new List<t>();

     controlsFound.AddRange(control.Controls.OfType<t>());
     foreach (Control c in control.Controls)
     {
       controlsFound.AddRange(FindControlByName<t>(c));
     }
     return controlsFound;
   }
 }

and perform:

C#
this.FindControlByName<textbox>().ToList().ForEach(t => t.Clear());

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --