c# – 如何在Windows窗体中获取按钮控件 – 面板
发布时间:2020-12-15 18:23:18 所属栏目:百科 来源:网络整理
导读:获取表格中的所有按钮,包括 相同形式的面板中的按钮.. 解决方法 ListControl list = new ListControl(); GetAllControl(this,list); foreach (Control control in list) { if (control.GetType() == typeof(Button)) { //all btn } } private void GetAllCon
|
获取表格中的所有按钮,包括
相同形式的面板中的按钮.. 解决方法List<Control> list = new List<Control>();
GetAllControl(this,list);
foreach (Control control in list)
{
if (control.GetType() == typeof(Button))
{
//all btn
}
}
private void GetAllControl(Control c,List<Control> list)
{
foreach (Control control in c.Controls)
{
list.Add(control);
if (control.GetType() == typeof(Panel))
GetAllControl(control,list);
}
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
