Freigeben über


Form.AutoScroll-Eigenschaft

Ruft einen Wert ab, der angibt, ob das Formular den automatischen Bildlauf ermöglicht, oder legt diesen fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<LocalizableAttribute(True)> _
Public Overrides Property AutoScroll As Boolean
'Usage
Dim instance As Form
Dim value As Boolean

value = instance.AutoScroll

instance.AutoScroll = value
[LocalizableAttribute(true)] 
public override bool AutoScroll { get; set; }
[LocalizableAttribute(true)] 
public:
virtual property bool AutoScroll {
    bool get () override;
    void set (bool value) override;
}
/** @property */
public boolean get_AutoScroll ()

/** @property */
public void set_AutoScroll (boolean value)
public override function get AutoScroll () : boolean

public override function set AutoScroll (value : boolean)

Eigenschaftenwert

true, um den automatischen Bildlauf für das Formular zu aktivieren, andernfalls false. Der Standardwert ist false.

Hinweise

Wenn diese Eigenschaft auf true festgelegt wird, werden im Formular Bildlaufleisten angezeigt, sobald sich ein Steuerelement außerhalb des Clientbereichs des Formulars befindet. Zudem wird bei aktiviertem automatischem Bildlauf automatisch ein Bildlauf des Clientbereichs des Formulars durchgeführt, um das Steuerelement mit dem Eingabefokus anzuzeigen.

Mit dieser Eigenschaft können Sie verhindern, dass Benutzern Steuerelemente nicht mehr angezeigt werden, weil sie eine niedrige Grafikauflösung eingestellt haben.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie mit der AutoScroll-Eigenschaft die Anzeige von Steuerelementen außerhalb des Clientbereichs eines Formulars ermöglicht wird. Im Beispiel wird ein neues Formular erstellt, und diesem wird ein Button-Steuerelement hinzugefügt. Das Button-Steuerelement befindet sich außerhalb des Clientbereichs des neuen Formulars. Die AutoScroll-Eigenschaft wird auf true festgelegt, um im Formular Bildlaufleisten anzuzeigen, damit der Benutzer einen Bildlauf zum Steuerelement durchführen kann. Für dieses Beispiel ist es erforderlich, dass die hier definierte Methode aus einem anderen Formular in einem Ereignishandler oder über eine andere Methode aufgerufen wird.

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
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:
   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.set_Text("Scrolled Button");

    // Set the size of the button.
    button1.set_Size(new Size(100, 30));

    // Set the location of the button to be outside the form's client area.
    button1.set_Location(new Point(form2.get_Size().get_Width() + 200, 
        form2.get_Size().get_Height() + 200));

    // Add the button control to the new form.
    form2.get_Controls().Add(button1);

    // Set the AutoScroll property to true to provide scrollbars.
    form2.set_AutoScroll(true);

    // Display the new form as a dialog box.
    form2.ShowDialog();       
} //DisplayMyScrollableForm  

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0

Siehe auch

Referenz

Form-Klasse
Form-Member
System.Windows.Forms-Namespace