private Control FindControl(Control container, string controlName) // 参数1为容器 参数2为控件名称
{
if (container.Name == controlName)
{
return container;
}
Control findControl = null;
foreach (Control control in container.Controls)
{ Console.WriteLine(control.Name);
if (control.Controls.Count == 0)
{
if (control.Name == controlName)
{
findControl = control; break;
}
}
else
{
findControl = FindControl(control, controlName);
if (findControl != null)
{
break;
}
}
}
return findControl;
}
C# 查找指定名称的控件
最新推荐文章于 2023-11-11 08:49:58 发布

2639

被折叠的 条评论
为什么被折叠?



