Form.DesktopLocation 屬性

定義

取得或設定 Windows 桌面上表單的位置。

public:
 property System::Drawing::Point DesktopLocation { System::Drawing::Point get(); void set(System::Drawing::Point value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point DesktopLocation { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DesktopLocation : System.Drawing.Point with get, set
Public Property DesktopLocation As Point

屬性值

Point,代表桌面上表單的位置。

屬性

範例

下列範例會設定表單的位置,讓表單位於桌面左框線的 100 圖元,以及桌面頂端的 100 圖元。 此範例要求方法已在表單類別內定義。

public:
   void MoveMyForm()
   {
      // Create a Point object that will be used as the location of the form.
      Point tempPoint = Point( 100, 100 );
      // Set the location of the form using the Point object.
      this->DesktopLocation = tempPoint;
   }
public void MoveMyForm()
 {
    // Create a Point object that will be used as the location of the form.
    Point tempPoint = new Point(100,100);
    // Set the location of the form using the Point object.
    this.DesktopLocation = tempPoint;
 }
Public Sub MoveMyForm()
    ' Create a Point object that will be used as the location of the form.
    Dim tempPoint As New Point(100, 100)
    ' Set the location of the form using the Point object.
    DesktopLocation = tempPoint
End Sub

備註

桌面座標是以螢幕的工作區域為基礎,這會排除工作列。 桌面的座標系統是以圖元為基礎。 如果您的應用程式是在多監視系統上執行,則表單的座標是合併桌面的座標。

您可以使用這個屬性,將表單相對於 Windows 桌面上的其他表單和應用程式放置。

如果您在呼叫 Show 方法之前呼叫 SetDesktopLocation 方法,您的表單會位於其預設位置,由作業系統決定。 如需視窗定位的詳細資訊,請參閱一文的 視窗大小和位置 一節。

如果您在呼叫 之後呼叫 SetDesktopLocationShow ,您的表單將會位於您指定的位置。

適用於

另請參閱