-2

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

Community
  • 1
  • 1
Bohn
  • 26,091
  • 61
  • 167
  • 254

1 Answers1

1

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)

Krishna
  • 688
  • 1
  • 7
  • 10