foreach (System.Windows.Forms.Control control in this.groupBox1.Controls)//遍历groupBox1上的所有控件
{
if (control is System.Windows.Forms.Button) //如果是button
{
//////////////////////////////
}
}
int buttonNumber;
foreach (Control c in groupbox.Controls )
{
if (c is Button)
buttonNumber++;
}
不知道这样行不行………
foreach(Control var in groupbox.Controls)
{
}