Export (0) Print
Expand All

Form.DesktopLocation Property

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

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public Point DesktopLocation { get; set; }
/** @property */
public Point get_DesktopLocation ()

/** @property */
public void set_DesktopLocation (Point value)

public function get DesktopLocation () : Point

public function set DesktopLocation (value : Point)

Property Value

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

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" document in the MSDN library at http://msdn.microsoft.com/library.

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

The following code 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;
 }
   

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.set_DesktopLocation(tempPoint);
} //MoveMyForm

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft