开发者

how to get the location on a Control that is inside another control [duplicate]

开发者 https://www.devze.com 2023-04-06 07:20 出处:网络
This question already has answers here: 开发者_C百科 Closed 11 years ago. Possible Duplicate: C# Get a control's position on a form
This question already has answers here: 开发者_C百科 Closed 11 years ago.

Possible Duplicate:

C# Get a control's position on a form

C# Winforms: I have a big table layout that it has some panels inside it and they have some listboxes inside those panels with Dock->Fill, so if I say listbox.Top it will be Zero... but I want to know the location based on the X,Y of the Form or at least that tableLayout, How can I do that? thanks


For this, you need to consider the location from Parent Control.

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消