Form.AutoScroll Właściwość

Definicja

Pobiera lub ustawia wartość wskazującą, czy formularz umożliwia automatyczne wyrejestrowanie.

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

Wartość właściwości

Boolean

true w celu włączenia automatycznego wyrejestrowywania w formularzu; w przeciwnym razie , false. Wartość domyślna to false.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą AutoScroll właściwości włączyć wyświetlanie kontrolek, które są poza rozmiarem obszaru klienta formularza. Przykład tworzy nowy formularz i dodaje kontrolkę Button do formularza. Kontrolka Button jest ustawiana na rozmiar poza obszar klienta nowego formularza. Właściwość jest ustawiona AutoScroll na wartość true, aby wyświetlić paski przewijania w formularzu, aby umożliwić użytkownikowi przewijanie do kontrolki. Ten przykład wymaga, aby metoda zdefiniowana w tym przykładzie została wywołana z innego formularza w procedurze obsługi zdarzeń lub innej metody.

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

Uwagi

Jeśli ta właściwość jest ustawiona na truewartość , paski przewijania są wyświetlane w formularzu, jeśli jakiekolwiek kontrolki znajdują się poza regionem klienta formularza. Ponadto podczas automatycznego wyrejestrowywania obszar klienta formularza automatycznie przewija się, aby kontrolka z fokusem wejściowym był widoczny.

Tej właściwości można użyć, aby uniemożliwić użytkownikom utratę możliwości wyświetlania kontrolek, gdy ich ustawienia rozdzielczości wideo są ustawione na niską rozdzielczość.

Dotyczy