Form.DesktopLocation Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur lokasi formulir pada desktop 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
Nilai Properti
Point yang mewakili lokasi formulir di desktop.
- Atribut
Contoh
Contoh berikut mengatur posisi formulir sehingga formulir diposisikan 100 piksel dari batas kiri desktop dan 100 piksel dari bagian atas desktop. Contoh ini mengharuskan metode tersebut telah ditentukan dalam kelas formulir.
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
Keterangan
Koordinat desktop didasarkan pada area kerja layar, yang mengecualikan taskbar. Sistem koordinat desktop berbasis piksel. Jika aplikasi Anda berjalan pada sistem multimonitor, koordinat formulir adalah koordinat untuk desktop gabungan.
Anda dapat menggunakan properti ini untuk memposisikan formulir Anda relatif terhadap formulir dan aplikasi lain di desktop Windows.
Jika Anda memanggil SetDesktopLocation metode sebelum memanggil Show metode , formulir Anda akan diposisikan di lokasi defaultnya, yang ditentukan oleh sistem operasi. Untuk informasi selengkapnya tentang penempatan jendela, lihat bagian Ukuran Jendela dan Posisi dari artikel "Fitur Jendela".
Jika Anda memanggil SetDesktopLocation setelah memanggil Show, formulir Anda akan diposisikan di lokasi yang Anda tentukan.