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 デスクトップ上の他のフォームやアプリケーションに対してフォームを相対的に配置できます。

メソッドを SetDesktopLocation 呼び出す前に メソッドを Show 呼び出すと、フォームはオペレーティング システムによって決定される既定の場所に配置されます。 ウィンドウの配置の詳細については、「ウィンドウ機能」の記事の「 ウィンドウのサイズと位置 」セクションを参照してください。

を呼び出した後に を呼び出SetDesktopLocationShowすと、フォームは指定した場所に配置されます。

適用対象

こちらもご覧ください