如何找到一个控制的位置的基础上控制的名字

0

的问题

我想基本上找到一个控制的位置的基础上的名字。 这是我迄今为止:

private Point FindControlLocation(string ControlName, Control ParentControl)
{
    //Code...
}

感谢任何的帮助!

c# controls winforms
2021-11-12 23:53:57
1

最好的答案

1

你其实不需要父母控制,只是使用的形式和递归的选项 Controls.Find():

private Point FindControlLocation(string ControlName)
{
    Control ctl = this.Controls.Find(ControlName, true).FirstOrDefault() as Control;
    return (ctl != null) ? ctl.Location : new Point();
}
2021-11-13 01:54:51

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................