Link to home
Start Free TrialLog in
Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America

asked on

Getting the absolute position of a control on a form?

I am trying to figure out how to get the absolute position of a control. I know about the Top/Left properties. The scenario is that I have a MDI form and ChildForms within it.

I'm trying to figure out what the Top/Left values are for a control on a ChildForm in relation to where the ChildForm is located within the MDI Form.

Thanks,
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Use Form.PointToScreen() in the ChildForm to convert the controls client coords to screen coords.  Then pass that to the MdiParent and use Form.PointToClient() to convert those screen coords back to client coords.

*You can also use the Control itself to get its own screen coords.  Pass the Point (0, 0) to its PointToScreen() method:

    Dim pt As Point = PictureBox1.PointToScreen(New Point(0, 0))
Avatar of BlakeMcKenna

ASKER

Can you show me an example please...
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Idle_Mind....exactly what I was looking for!