NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Setting the Location of Win Forms

You can specify where a form is to be displayed on the computer screen by setting the Location property. This specifies the 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.

Note   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.

Note   Keep in mind that screen size and resolution may differ on your user's system. A form's location as a user sees it might thus differ from what you see when you set the Location property.

To position forms programmatically

To change form position by increments

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 desktop location of (0, 0) always appears in the upper left corner of the primary monitor, but not under the taskbar.

To set the Desktop Location property programmatically

See Also

Introduction to Win Forms | Win Forms Creation | Positioning Controls on Win Forms | Anchoring Controls on Win Forms | Docking Controls on Win Forms | Displaying Modal and Modeless Forms |Creating Transparent Win Forms | Resizing Win Forms | Dialog Boxes