Form.DesktopBounds 属性

定义

获取或设置 Windows 桌面上窗体的大小和位置。

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

属性值

Rectangle,它使用桌面坐标表示 Windows 桌面上窗体的边界。

属性

示例

以下示例设置窗体的大小和位置,使窗体定位到距桌面左边框 50 像素、距桌面顶部 50 像素的位置。 此示例要求在窗体类中定义 方法。

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

注解

桌面坐标基于屏幕的工作区域,这不包括任务栏。 桌面的坐标系基于像素。 如果应用程序在多个监视系统上运行,则窗体的坐标是组合桌面的坐标。

可以使用此属性相对于 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

另请参阅