Form.TopMost 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 menetapkan nilai yang menunjukkan apakah formulir harus ditampilkan sebagai formulir paling atas.
public:
property bool TopMost { bool get(); void set(bool value); };
public bool TopMost { get; set; }
member this.TopMost : bool with get, set
Public Property TopMost As Boolean
Nilai Properti
true untuk menampilkan formulir sebagai formulir paling atas; jika tidak, false. Defaultnya adalah false.
Contoh
Contoh berikut menunjukkan cara membuat formulir paling atas. Contohnya membuat dua bentuk, satu yang dimaksimalkan dan satu yang akan ditampilkan sebagai bentuk paling atas. Formulir pertama, bernama bottomForm, ditampilkan dimaksimalkan, menggunakan WindowState properti , untuk lebih menunjukkan kemampuan formulir paling atas. Formulir kedua, bernama topMostForm, mengatur TopMost properti ke untuk true menampilkan formulir sebagai formulir paling atas. Ketika kode ini dijalankan, mengklik formulir yang dimaksimalkan tidak akan menyebabkan formulir paling atas ditampilkan di bawah formulir yang dimaksimalkan. Contoh mengharuskan metode yang ditentukan dalam contoh dipanggil dari formulir lain.
private:
void CreateMyTopMostForm()
{
// Create lower form to display.
Form^ bottomForm = gcnew Form;
// Display the lower form Maximized to demonstrate effect of TopMost property.
bottomForm->WindowState = FormWindowState::Maximized;
// Display the bottom form.
bottomForm->Show();
// Create the top most form.
Form^ topMostForm = gcnew Form;
// Set the size of the form larger than the default size.
topMostForm->Size = System::Drawing::Size( 300, 300 );
// Set the position of the top most form to center of screen.
topMostForm->StartPosition = FormStartPosition::CenterScreen;
// Display the form as top most form.
topMostForm->TopMost = true;
topMostForm->Show();
}
private void CreateMyTopMostForm()
{
// Create lower form to display.
Form bottomForm = new Form();
// Display the lower form Maximized to demonstrate effect of TopMost property.
bottomForm.WindowState = FormWindowState.Maximized;
// Display the bottom form.
bottomForm.Show();
// Create the top most form.
Form topMostForm = new Form();
// Set the size of the form larger than the default size.
topMostForm.Size = new Size(300,300);
// Set the position of the top most form to center of screen.
topMostForm.StartPosition = FormStartPosition.CenterScreen;
// Display the form as top most form.
topMostForm.TopMost = true;
topMostForm.Show();
}
Private Sub CreateMyTopMostForm()
' Create lower form to display.
Dim bottomForm As New Form()
' Display the lower form Maximized to demonstrate effect of TopMost property.
bottomForm.WindowState = FormWindowState.Maximized
' Display the bottom form.
bottomForm.Show()
' Create the top most form.
Dim topMostForm As New Form()
' Set the size of the form larger than the default size.
topMostForm.Size = New Size(300, 300)
' Set the position of the top most form to center of screen.
topMostForm.StartPosition = FormStartPosition.CenterScreen
' Display the form as top most form.
topMostForm.TopMost = True
topMostForm.Show()
End Sub
Keterangan
Bentuk paling atas adalah bentuk yang tumpang tindih dengan semua bentuk lainnya (non-atas) bahkan jika itu bukan bentuk aktif atau latar depan. Formulir paling atas selalu ditampilkan pada titik tertinggi dalam urutan z jendela di desktop. Anda dapat menggunakan properti ini untuk membuat formulir yang selalu ditampilkan di aplikasi Anda, seperti jendela alat Temukan dan Ganti.