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

另請參閱