Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I make a UserControl to find its own position on the screen ?

Status
Not open for further replies.

Toranaga

Programmer
Nov 14, 2002
11
RO
The problem is very simple : I have a UserControl placed on a form. The UserControl has a Command Button on it. When I click the button, I want a msgbox to appear and say the coordinates of the Control on the screen.
I have no idea how I could do that (as a matter of fact, I don't know either how to make the UserControl show its coordinates of the of the form, in the same way as above).
Anyone can provide help ?
 
To reference the value of the usercontrol Top and Left location on it's container from inside the control, use these properties:

Extender.Left
Extender.Top

From this, you can figure out the location of the command button by referring to it's Top and Left properties inside the usercontrol itself.

UserControl.<CommandButtonName>.Left
UserControl.<CommandButtonName>.Top

and adding the two top values and left values together.

Make sure you are using the same scalemode for the form and the user control before you add them.

UserControl.ScaleMode
Parent.ScaleMode

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top