遍历控件内控件
遍历返回的list
CheckBox[] cl = GetLableList(tabPage1).ToArray<CheckBox>();
foreach (CheckBox c in cl)
{
MessageBox.Show(c.Name);
}
传入控件检查空间内CheckBox添加到list
private List<CheckBox> GetLableList(Control ctro)
{
List<CheckBox> list =new List<CheckBox>();
foreach (object var in ctro.Controls)
{
if (var is CheckBox)
{
list.Add((CheckBox)var);
}
}
return list;
}