|
-
Jan 16th, 2007, 08:07 AM
#1
Re: [2005] Find out all location co-ordinates of control
All controls have Location, Size, Width, Height, Top, Left, Bottom and Right properties. The following are true:
Location.X = Left
Location.Y = Top
Size.Width = Width
Size.Height = Height
Bottom = Top + Height
Right = Left + Width
Location, Size, Top, Left, Height and Width can all be set at run time. Location.X, Location.Y, Size.Height, Size.Width, Bottom and Right cannot.
The Location, Top, Bottom, Left and Right properties are in relation to the top, left corner of the control's parent. You can convert a point in a controls coordinate system to screen coordinates and back using that control's PointToScreen and PointToClient methods. For instance, if you place a Panel on a form the following code will give you the coordinates of the Panel relative to the top, left corner of the screen:
VB Code:
Dim pt As Point = Me.PointToScreen(Me.Panel1)
-
Jan 16th, 2007, 08:40 AM
#2
Thread Starter
Frenzied Member
Re: [2005] Find out all location co-ordinates of control
Thanks guys, I've got all the info I need now. I came across the PointToScreen option just as you posted JMC.
It came up with a different value to my location value for my picturebox but realised they are measured in relation to different things.
Cheers for the useful info.
EDIT: JMC I think it needs to be
VB Code:
Dim pt As Point = Me.PointToScreen(Me.Panel1.Location)
Last edited by stimbo; Jan 16th, 2007 at 09:07 AM.
-
Jan 16th, 2007, 04:54 PM
#3
Re: [2005] Find out all location co-ordinates of control
 Originally Posted by stimbo
Thanks guys, I've got all the info I need now. I came across the PointToScreen option just as you posted JMC.
It came up with a different value to my location value for my picturebox but realised they are measured in relation to different things.
Cheers for the useful info.
EDIT: JMC I think it needs to be
VB Code:
Dim pt As Point = Me.PointToScreen(Me.Panel1.Location)
I think someone deleted the ".Location" from my post just to make me look bad.
-
Jan 16th, 2007, 08:15 PM
#4
Thread Starter
Frenzied Member
Re: [RESOLVED] [2005] Find out all location co-ordinates of control
The scoundrels! They do it to me all the time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|