日期:2014-05-18 浏览次数:21215 次
foreach(Control ctl in Controls) { if(ctl is Button) //or if(ctl.GetType()==(new Button()).GetType) .. //其它类似 }
------解决方案--------------------
考虑容器控件. 若button在容器里.
private void seachbutton(Control.ControlCollection controls) { foreach (Control c in controls) { if (c is Button) { .....} else if (c.Controls.Count > 0) seachbutton(c.Controls); } }