110,912
社区成员
发帖
与我相关
我的任务
分享
private Control FindControl(Control container, string controlName)
{
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;
}