用递归的方式遍历窗体下的所有控件
代码
privatevoid allCtl(Control ctl)
{
foreach (Control c in ctl.Controls)
{
if (c.Controls.Count <1)
{
//do what you want;
break;
}
else
{
allCtl(c);
}
}
}
{
foreach (Control c in ctl.Controls)
{
if (c.Controls.Count <1)
{
//do what you want;
break;
}
else
{
allCtl(c);
}
}
}