How to: Set the Screen Location of Windows Forms
You can specify where a form is to be displayed on the computer screen by entering values in the Location property. This specifies the position, in pixels, of the top-left corner of the form. Also, you need to set the StartPositionproperty to indicate the boundaries of the display area.
Keep in mind that screen size and resolution often vary depending on the user's system. Additionally, systems that have multiple monitors attached may have trouble recognizing the boundaries of the display area. These two situations will often cause a form's location to change unpredictably, despite the Location property setting. For this reason, the default setting for the StartPosition property for a Windows Application is WindowsDefaultLocation, which tells the operating system to compute the best location for the form at startup, based on the current hardware. Another alternative is to set the StartPosition property to Center and then change the location of the form in code. See "To position forms programmatically" below for more information.
To position forms using the Properties window
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.
To position forms programmatically
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). The following example adjusts the form's X coordinate to the 300 pixel point:
To change form position programmatically by increments
Increment the X coordinate of the form using the Left property. The following example adjusts the form's X coordinate by 200 pixels:
Use the Location property to set a Windows Form's X and Y positions simultaneously. To set them individually, use the form's Left (X) or Top (Y) property. Do not try to implicitly set the X and Y coordinates of the Point structure that represents the form's location, because this contains a copy of the form's coordinates.
In lieu of using the Location property, the DesktopLocation property can be used to set the location of your form. This property sets the location of your form relative to the taskbar and is useful if the taskbar has been docked to the top or left of the user's monitor. Docking the taskbar in this fashion obscures the desktop coordinates (0,0). A form with the DesktopLocationproperty set to (0, 0) always appears in the upper left corner of the primary monitor, but not behind the taskbar.