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
views:
22answers:
2
A:
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...
Mahmoud Younes
2010-08-22 06:55:32
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
2010-08-22 07:07:53
+2
A:
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
2010-08-22 06:57:38
yeah this one works :)and if i have a nested group box then what will be the method?
Karim
2010-08-22 07:10:21
Karim, I think is the same. Just use the parent's `PointToScreen` method for the control you want.
Victor Hurdugaci
2010-08-22 07:53:39