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 |