Form.DesktopBounds Form.DesktopBounds Form.DesktopBounds Form.DesktopBounds Property

定义

获取或设置 Windows 桌面上窗体的大小和位置。Gets or sets the size and location of the form on the Windows desktop.

public:
 property System::Drawing::Rectangle DesktopBounds { System::Drawing::Rectangle get(); void set(System::Drawing::Rectangle value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Rectangle DesktopBounds { get; set; }
member this.DesktopBounds : System.Drawing.Rectangle with get, set
Public Property DesktopBounds As Rectangle

属性值

Rectangle,它使用桌面坐标表示 Windows 桌面上窗体的边界。A Rectangle that represents the bounds of the form on the Windows desktop using desktop coordinates.

示例

下面的代码示例设置的大小和窗体的位置,以便该窗体是距左边框的顶部的桌面的桌面到 50 个像素。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.

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;
   }
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;
 }
   
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

注解

桌面坐标相对于屏幕,其中不包括任务栏的工作区。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.

此属性可用于调整大小和在 Windows 桌面上的位置相对于其他窗体或应用程序的窗体。You can use this property to size and position a form relative to other forms or applications on the Windows desktop.

适用于

另请参阅