2

well i was PointToScreen() but when the control is inside a group box this method dont work and gives me wrong coordinates.
so is there is anyother method to get the position of a control inside a group box control?
i need that screen position so i can display a dialog near that control.
thanks

Karim
  • 6,113
  • 18
  • 58
  • 83

2 Answers2

5

Probably you are using PointToScreen on the wrong control...

If you have a groupbox with a button then the following code works just fine:

Point p = groupBox1.PointToScreen(button1.Location);
Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103
2

I am not sure about this, but I think you can add the locations of the component and its containers.

For example, if you have a textbox inside a groupbox, you can do this:

Point p = textbox.location + groupbox.location + this.location;

"this.location" is used to get the location of the main form on the screen

Hope this will help...

  • i know this method but i didnt want to use it. this is why i asked on stackoverflow this question cause they should be a better way – Karim Aug 22 '10 at 07:07