Form.DesktopBounds Property

Definition

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

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

Property Value

A Rectangle that represents the bounds of the form on the Windows desktop using desktop coordinates.

Attributes

Examples

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

public void MoveMyForm()
 {
    // Create a Rectangle object that will be used as the bound of the form.
    Rectangle tempRect = new Rectangle(50,50,100,100);
    //  Set the bounds of the form using the Rectangle object.
    this.DesktopBounds = tempRect;
 }

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 multiple monitor system, the coordinates of the form are the coordinates for the combined desktop.

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

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