Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

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

, 2 Oct 2011
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

Comments and Discussions

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