- void cleardata() {
- Action < Control.ControlCollection > func = null;
- func = (controls) => {
- foreach(Control control in controls)
- if (control is TextBox)
- (control as TextBox).Clear();
- else if (control is ComboBox)
- (control as ComboBox).SelectedIndex = 0;
- else
- func(control.Controls);
- };
- func(Controls);
- }
This code will clear all the text boxes and combo boxes available in the particular form where you are executing. if you wanted to clear more control then specify in the if condition
