跟FORM差不多,遍历时指定为groupbox中的控件就行了! foreach (Control ctl in this.groupBox1.Controls) { MessageBox.Show(ctl.Name.ToString()); }
foreach(ctrl c in this.groupbox1.Controls) { .... }Form: foreach(ctrl c in this.Controls) { if (ctrl is GroupBox) { foreach(gc c in ctrl.Controls) { .... } } .... }
foreach(control c in this.Controls) { if(c is Groupbox)//加上这个条件就可以了 { MessageBox.show(c.Name) } }
foreach (Control ctl in this.groupBox1.Controls)
{
MessageBox.Show(ctl.Name.ToString());
}
{
....
}Form:
foreach(ctrl c in this.Controls)
{
if (ctrl is GroupBox)
{
foreach(gc c in ctrl.Controls)
{
....
}
} ....
}
{
if(c is Groupbox)//加上这个条件就可以了
{
MessageBox.show(c.Name)
}
}