Groups | Blog | Home
all groups > dotnet windows forms controls > december 2005 >

dotnet windows forms controls : Absolute Control Location


David A. Schramm
12/31/2005 2:59:11 PM
If a control is inside a group box, how do you find its absolute location on
a form?
The location values show its location relative to the group box upper left
corner.

Thanks.

Tim Wilson
12/31/2005 8:55:00 PM
You can use the PointToScreen and PointToClient methods to accomplish this.
Assuming that there is a Button named "button1" that is inside a GroupBox
named "groupBox1", you can use the following code to get the location of
"button1" relative to the Forms upper left corner.

this.PointToClient(this.groupBox1.PointToScreen(this.button1.Location));

--
Tim Wilson
..NET Compact Framework MVP

[quoted text, click to view]

AddThis Social Bookmark Button