Click here to Skip to main content
12,397,805 members (54,444 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3K views
Posted

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

, 2 Oct 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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:

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:

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)

Share

About the Author

kris444
India India
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 2 Oct 2011
Article Copyright 2011 by kris444
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid