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 桌面上的其他表單或應用程式。

適用於

另請參閱