How to measure form locations

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
2 posts Page 1 of 1
Contributors
User avatar
froza
Just Registered
Just Registered
Posts: 7
Joined: Thu Feb 24, 2011 4:56 pm

How to measure form locations
froza
The subject might not be easy to understand, but let's take an example, you're application have 2 forms, and you wanted both the forms to stick together at anywhere, anytime, so one of the form must be a reference point to the other form.
I wanted the 2nd form to be on the top left of the 1st form(reference point), so to calculate the location for the 2nd form will be like the following formula :
Code: Select all
Form1.Location.X - Form1.size.width, Form1.Location.Y - Form1.size.height
In order to calculate other locations, here's the explanation to the formula :
Form1.Location.X - Form1.size.width = Left
Form1.Location.X + Form1.size.width = Right
Form1.Location.Y + Form1.size.height = Bottom
Form1.Location.Y - Form1.size.height = Top
Here, I've pre-calculated some of the basic locations :
bottom left :
Code: Select all
Form1.Location.X - Form1.size.width, Form1.Location.Y + Form1.size.height
bottom right :
Code: Select all
Form1.Location.X + Form1.size.width, Form1.Location.Y + Form1.size.height
top left :
Code: Select all
Form1.Location.X - Form1.size.width, Form1.Location.Y - Form1.size.height
top right :
Code: Select all
Form1.Location.X + Form1.size.width, Form1.Location.Y - Form1.size.height
You do not have the required permissions to view the files attached to this post.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: How to measure form locations
MrAksel
Very nice tutorial, this is a cool thing to have in every program! Great work and welcome to the site!
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
2 posts Page 1 of 1
Return to “Tutorials”