Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Form.DesktopBounds Property

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

[Visual Basic]
Public Property DesktopBounds As Rectangle
[C#]
public Rectangle DesktopBounds {get; set;}
[C++]
public: __property Rectangle get_DesktopBounds();
public: __property void set_DesktopBounds(Rectangle);
[JScript]
public function get DesktopBounds() : Rectangle;
public function set DesktopBounds(Rectangle);

Property Value

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

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.

Example

[Visual Basic, C#, C++] 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 top of the desktop. This example assumes that the method is defined within a form class.

[Visual Basic] 
Public Sub MoveMyForm()
    ' Create a Rectangle object that will be used as the bound of the form.
    Dim tempRect As New Rectangle(50, 50, 100, 100)
    '  Set the bounds of the form using the Rectangle object.
    DesktopBounds = tempRect
End Sub 'MoveMyForm

[C#] 
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;
 }
   

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Form Class | Form Members | System.Windows.Forms Namespace | DesktopLocation

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft