【问题标题】:how to get the location on a Control that is inside another control [duplicate]如何在另一个控件内的控件上获取位置[重复]
【发布时间】:2011-11-22 05:37:19
【问题描述】:

可能重复:
C# Get a control's position on a form

C# Winforms:我有一个大表格布局,里面有一些面板,并且在这些面板中有一些列表框,带有 Dock->Fill,所以如果我说 listbox.Top 它将为零......但我想要要知道基于表单的 X、Y 或至少该 tableLayout 的位置,我该怎么做?谢谢

【问题讨论】:

    标签: c# winforms


    【解决方案1】:

    为此,您需要考虑父控件的位置。

    Control(X, Y) = ( UserControl.Location.X (@Parent Control) + Control.Location.X (@UserControl) ,
    UserControl.Location.Y(@父控件)+ Control.Location.Y(@UserControl))

    X = UserControl.Location.X (@Parent Control) + Control.Location.X (@UserControl)
    Y = UserControl.Location.Y(@父控件)+ Control.Location.Y(@UserControl)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-27
      • 2010-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-14
      • 2011-05-05
      • 2010-12-01
      相关资源
      最近更新 更多