>public virtual void ClearData() >{ > foreach (Control c in this.Controls) > this.ClearControl(c); > >} > > >private void ClearControl(Control c) >{ > if (c.Controls.Count > 0) > for (int i = 0; i < c.Controls.Count; i++) > ClearControl(c.Controls[i]); > else > { > 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(); > } > } >} >The groupbox is a container control in itself. You'll probably need to iterate the GroupBox.Controls collection also.