Form.DesktopLocation Property

Definition

Gets or sets the location of the form on the Windows desktop.

[System.ComponentModel.Browsable(false)]
public System.Drawing.Point DesktopLocation { get; set; }

Property Value

A Point that represents the location of the form on the desktop.

Attributes

Examples

The following example sets the position of a form so that the form is positioned 100 pixels from the left border of the desktop and 100 pixels from the top of the desktop. This example requires that method has been defined within a form class.

public void MoveMyForm()
 {
    // Create a Point object that will be used as the location of the form.
    Point tempPoint = new Point(100,100);
    // Set the location of the form using the Point object.
    this.DesktopLocation = tempPoint;
 }

Remarks

Desktop coordinates are based on the working area of the screen, which excludes the taskbar. The coordinate system of the desktop is pixel based. If your application is running on a multimonitor system, the coordinates of the form are the coordinates for the combined desktop.

You can use this property to position your form relative to other forms and applications on the Windows desktop.

If you call the SetDesktopLocation method before calling the Show method, your form will be positioned at its default location, which is determined by the operating system. For more information about window positioning, see the Window Size and Position section of the "Window Features" article.

If you call SetDesktopLocation after calling Show, your form will be positioned at the location you specified.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also