Skip to main content

Posts

Showing posts with the label Common way to clear all control on form in c sharp dot net

Common way to clear all control on form in c sharp dot net

This a Common way to clear all control on form using c sharp dot net code. In you common class you can write following code in method and you can call that method in any form using class object. foreach (Control C in CTRL.Controls) { if (C.GetType() == typeof(MaskedTextBox)) { C.Text = ""; } else if (C.GetType() == typeof(TextBox)) { C.Text = ""; } else if (C.GetType() == typeof(ComboBox)) { ComboBox cbox = (ComboBox)C; cbox.SelectedIndex = -1; } else if (C.GetType() == typeof(CheckBox)) { CheckBox chkbox = (CheckBox)C; chkbox.Checked = false; } else if (C.GetType() == typeof(ListBox)) { ListBox lstbox = (ListBox)C; lstbox.Items.Clear(); } else if (C.GetType() == typeof(DateTime...