Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 2.0
Form Class
Form Properties
 DesktopBounds Property

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework Class Library
Form.DesktopBounds Property

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

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

Visual Basic (Declaration)
Public Property DesktopBounds As Rectangle
Visual Basic (Usage)
Dim instance As Form
Dim value As Rectangle

value = instance.DesktopBounds

instance.DesktopBounds = value
C#
public Rectangle DesktopBounds { get; set; }
C++
public:
property Rectangle DesktopBounds {
    Rectangle get ();
    void set (Rectangle value);
}
J#
/** @property */
public Rectangle get_DesktopBounds ()

/** @property */
public void set_DesktopBounds (Rectangle value)
JScript
public function get DesktopBounds () : Rectangle

public function set DesktopBounds (value : Rectangle)

Property Value

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

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.

The following code 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.

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;
   }
J#
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.set_DesktopBounds(tempRect);
} //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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker