Form.AutoScroll 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 mengaktifkan pendaftaran otomatis.
public:
virtual property bool AutoScroll { bool get(); void set(bool value); };
public override bool AutoScroll { get; set; }
member this.AutoScroll : bool with get, set
Public Overrides Property AutoScroll As Boolean
Nilai Properti
true untuk mengaktifkan autoscrolling pada formulir; jika tidak, false. Defaultnya adalah false.
Contoh
Contoh berikut menunjukkan cara menggunakan AutoScroll properti untuk mengaktifkan tampilan kontrol yang menguraikan area klien formulir. Contoh membuat formulir baru dan menambahkan Button kontrol ke formulir. Kontrol Button diposisikan menguraikan ukuran area klien dari formulir baru. Properti AutoScroll diatur ke true untuk menampilkan bilah gulir pada formulir untuk memungkinkan pengguna menggulir ke kontrol. Contoh ini mengharuskan metode yang ditentukan dalam contoh ini dipanggil dari formulir lain dalam penanganan aktivitas atau metode lain.
private:
void DisplayMyScrollableForm()
{
// Create a new form.
Form^ form2 = gcnew Form;
// Create a button to add to the new form.
Button^ button1 = gcnew Button;
// Set text for the button.
button1->Text = "Scrolled Button";
// Set the size of the button.
button1->Size = System::Drawing::Size( 100, 30 );
// Set the location of the button to be outside the form's client area.
button1->Location = Point(form2->Size.Width + 200,form2->Size.Height + 200);
// Add the button control to the new form.
form2->Controls->Add( button1 );
// Set the AutoScroll property to true to provide scrollbars.
form2->AutoScroll = true;
// Display the new form as a dialog box.
form2->ShowDialog();
}
private void DisplayMyScrollableForm()
{
// Create a new form.
Form form2 = new Form();
// Create a button to add to the new form.
Button button1 = new Button();
// Set text for the button.
button1.Text = "Scrolled Button";
// Set the size of the button.
button1.Size = new Size(100,30);
// Set the location of the button to be outside the form's client area.
button1.Location = new Point(form2.Size.Width + 200, form2.Size.Height + 200);
// Add the button control to the new form.
form2.Controls.Add(button1);
// Set the AutoScroll property to true to provide scrollbars.
form2.AutoScroll = true;
// Display the new form as a dialog box.
form2.ShowDialog();
}
Private Sub DisplayMyScrollableForm()
' Create a new form.
Dim form2 As New Form()
' Create a button to add to the new form.
Dim button1 As New Button()
' Set text for the button.
button1.Text = "Scrolled Button"
' Set the size of the button.
button1.Size = New Size(100, 30)
' Set the location of the button to be outside the form's client area.
button1.Location = New Point(form2.Size.Width + 200, form2.Size.Height + 200)
' Add the button control to the new form.
form2.Controls.Add(button1)
' Set the AutoScroll property to true to provide scrollbars.
form2.AutoScroll = True
' Display the new form as a dialog box.
form2.ShowDialog()
End Sub
Keterangan
Jika properti ini diatur ke true, bilah gulir ditampilkan pada formulir jika ada kontrol yang terletak di luar wilayah klien formulir. Selain itu, ketika autoscrolling aktif, area klien formulir secara otomatis menggulir untuk membuat kontrol dengan fokus input terlihat.
Anda dapat menggunakan properti ini untuk mencegah pengguna kehilangan kemampuan untuk melihat kontrol saat pengaturan resolusi video mereka diatur ke resolusi rendah.