Form.DesktopBounds 属性
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 Windows 桌面上窗体的大小和位置。
public:
property System::Drawing::Rectangle DesktopBounds { System::Drawing::Rectangle get(); void set(System::Drawing::Rectangle value); };
C#
[System.ComponentModel.Browsable(false)]
public System.Drawing.Rectangle DesktopBounds { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DesktopBounds : System.Drawing.Rectangle with get, set
Public Property DesktopBounds As Rectangle
Rectangle,它使用桌面坐标表示 Windows 桌面上窗体的边界。
- 属性
以下示例设置窗体的大小和位置,使窗体定位到距桌面左边框 50 像素、距桌面顶部 50 像素的位置。 此示例要求在窗体类中定义 方法。
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;
}
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;
}
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
桌面坐标基于屏幕的工作区域,这不包括任务栏。 桌面的坐标系基于像素。 如果应用程序在多个监视系统上运行,则窗体的坐标是组合桌面的坐标。
可以使用此属性相对于 Windows 桌面上的其他窗体或应用程序调整窗体的大小和位置。
产品 | 版本 |
---|---|
.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, 10 |