Form.AutoScroll Propriété

Définition

Obtient ou définit une valeur indiquant si le formulaire permet le défilement automatique.

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

Valeur de propriété

Boolean

true pour activer le défilement automatique sur le formulaire ; sinon, false. La valeur par défaut est false.

Exemples

L’exemple suivant montre comment utiliser la AutoScroll propriété pour activer l’affichage des contrôles qui dépassent la zone cliente d’un formulaire. L’exemple crée un formulaire et ajoute un Button contrôle au formulaire. Le Button contrôle est positionné sur la zone cliente du nouveau formulaire. La AutoScroll propriété a la valeur true pour afficher les barres de défilement sur le formulaire pour permettre à l’utilisateur de faire défiler le contrôle. Cet exemple exige que la méthode définie dans cet exemple soit appelée à partir d’un autre formulaire dans un gestionnaire d’événements ou une autre méthode.

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

Remarques

Si cette propriété est définie truesur , les barres de défilement s’affichent sur le formulaire si des contrôles se trouvent en dehors de la zone cliente du formulaire. En outre, lorsque l’inscription automatique est activée, la zone cliente du formulaire défile automatiquement pour rendre le contrôle visible par le focus d’entrée.

Vous pouvez utiliser cette propriété pour empêcher les utilisateurs de perdre la possibilité d’afficher les contrôles lorsque leurs paramètres de résolution vidéo sont définis sur une résolution faible.

S’applique à