110,546
社区成员
发帖
与我相关
我的任务
分享
private void seachbutton(Control.ControlCollection controls)
{
foreach (Control c in controls)
{
if (c is Button)
{ .....}
else
if (c.Controls.Count > 0)
seachbutton(c.Controls);
}
}
private List<Button> getButton()
{
foreach (Control c in this.Controls)
{
List<Button> list = new List<Button>();
if (c.GetType().ToString() == "System.Windows.Forms.Button")
{
list.Add(c);
}
}
return List;
}
foreach(Control ctl in Controls)
{
if(ctl is Button) //or if(ctl.GetType()==(new Button()).GetType)
..
//其它类似
}
foreach(Control c in this.Controls)
{
switch(c.GetType().Name.ToUpper())
{
case "Button":
default:
}
}
foreach(Control ctl in Controls)
{
...
}