ClearControls
public static void ClearControls(this System.Windows.Forms.Form form) { foreach(var item in form.Controls) { if (item is TextBox) (item as TextBox).Text = ""; if (item is ComboBox) (item as ComboBox).SelectedIndex = -1; //if (item is ...) } }Example:
//In a button 'Reset' click event in a WinForm this.ClearControls();
Description
clean the controls on a form. Please send suggestions.
Details
- Author: Wallison R Santos
- Submitted on: 6/22/2010 8:09:57 PM
- Language: C#
- Type: System.Windows.Forms.Form
- Views: 2549
Double click on the code to select all.