>public virtual void ClearData() > { > foreach (Control c in this.Controls) > if (c.Controls.Count > 0) > for (int i = 0; i < c.Controls.Count; i++) > ClearControl(c.Controls[i]); > else > this.ClearControl(c); > > } > > private void ClearControl(Control c) > { > > if (c is TextBox) > { > TextBox tb = (TextBox)c; > tb.Text = ""; > } > > if (c is CheckBox) > { > CheckBox chk = (CheckBox)c; > chk.Checked = false; > } > > if (c is ListView) > { > ListView lv = (ListView)c; > lv.Items.Clear(); > } > > if (c is DataGridView) > { > DataGridView dgv = (DataGridView)c; > dgv.Rows.Clear(); > } > } >Looks good. :)