Share via


Form.DesktopBounds Properti

Definisi

Mendapatkan atau mengatur ukuran dan lokasi formulir di desktop Windows.

public:
 property System::Drawing::Rectangle DesktopBounds { System::Drawing::Rectangle get(); void set(System::Drawing::Rectangle value); };
[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

Nilai Properti

Rectangle yang mewakili batas formulir pada desktop Windows menggunakan koordinat desktop.

Atribut

Contoh

Contoh berikut mengatur ukuran dan posisi formulir sehingga formulir diposisikan 50 piksel dari batas kiri desktop dan 50 piksel dari bagian atas desktop. Contoh ini mengharuskan metode didefinisikan dalam kelas formulir.

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;
   }
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

Keterangan

Koordinat desktop didasarkan pada area kerja layar, yang mengecualikan taskbar. Sistem koordinat desktop berbasis piksel. Jika aplikasi Anda berjalan pada sistem beberapa monitor, koordinat formulir adalah koordinat untuk desktop gabungan.

Anda dapat menggunakan properti ini untuk mengukur dan memposisikan formulir relatif terhadap formulir atau aplikasi lain pada desktop Windows.

Berlaku untuk

Lihat juga