foreach (Control ct in cntr.Controls) { if (ct is TextBox) { ((TextBox)ct).Clear(); } else if (ct.HasChildren) { ClearFields(ct); } else if (ct is ComboBox) { ((ComboBox)ct).SelectedIndex = -1; } else if (ct is RichTextBox) { ((RichTextBox)ct).Clear(); } else if (ct is DataGridView) { ((DataGridView)ct).Rows.Clear(); } }
datagridview1.Rows.Clear();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)