Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

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

0.00/5 (No votes)
2 Oct 2011 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here