【发布时间】:2021-12-25 05:38:23
【问题描述】:
我想基本上根据名称找到控件的位置。这是我目前所拥有的:
private Point FindControlLocation(string ControlName, Control ParentControl)
{
//Code...
}
感谢您的帮助!
【问题讨论】:
我想基本上根据名称找到控件的位置。这是我目前所拥有的:
private Point FindControlLocation(string ControlName, Control ParentControl)
{
//Code...
}
感谢您的帮助!
【问题讨论】:
您实际上并不需要父控件,只需使用 Controls.Find() 中的 Form 和递归选项:
private Point FindControlLocation(string ControlName)
{
Control ctl = this.Controls.Find(ControlName, true).FirstOrDefault() as Control;
return (ctl != null) ? ctl.Location : new Point();
}
【讨论】: