没看到问题,给你一个我的方法吧
递归获得所有checkbox
protected CheckBox[] GetAllCheckBox(ControlCollection controls)
{
List
if(controls.Count==0)
{
return cbList.ToArray();
}
else
{
foreach(Control item in controls)
{
if(item.Controls.Count!=0)
{
cbList.AddRange(GetAllCheckBox(item.Controls);
}
else if(item is CheckBox)
{
cbList.Add(item as CheckBox);
}
}
return cbList.ToArray();
}
}
然后调用GetAllCheckBox(Panel1.Controls);