You can specify where a form is to be displayed on the computer screen by entering values in the Location property. You can set position, in pixels, of the top-left corner of the form. Also, you need to set the StartPosition property to indicate the boundaries of the display area. The default start position is ‘WindowsDefaultLocation’
We can specify the initial position of a form with the help of Startposition property.
You can use ‘Startposition’ property with ‘FormStartPosition’ Enumeration, that has following members
|Manual||The position of the form is determined by the Location property.|
|CenterScreen||The form is centered on the current display, and has the dimensions specified in the form’s size.|
|WindowsDefaultLocation||The form is positioned at the Windows default location and has the dimensions specified in the form’s size.|
|WindowsDefaultBounds||The form is positioned at the Windows default location and has the bounds determined by Windows default.|
|CenterParent||The form is centered within the bounds of its parent form.|
You can set the location of the windows form using the Properties window,follow these steps:
1. Set the form’s StartPosition property to Manual.
2. Type the values for the Location property, separated by a comma, to position the form, where the first number (X) is the distance from the left border of the display area and second number (Y) is the distance from the upper border of the display area.
Now if you want to set the location pragmatically ten use this code sample :
Form1.Location = New Point(100, 100)
Form1.Location = new Point(100, 100);
or you can set the location with the help of Top and left property of the windows form means change the X coordinate or Y coordinate of the form’s location using the Left property (for the X coordinate) and the Top property (for the Y coordinate) like as :
Form1.Left = 200
Form1.Left = 200;