Partager via


ScrollableControl.ScrollControlIntoView(Control) Méthode

Définition

Fait défiler le contrôle enfant spécifié en mode affichage sur un contrôle activé pour le défilement automatique.

public:
 void ScrollControlIntoView(System::Windows::Forms::Control ^ activeControl);
public void ScrollControlIntoView(System.Windows.Forms.Control activeControl);
public void ScrollControlIntoView(System.Windows.Forms.Control? activeControl);
member this.ScrollControlIntoView : System.Windows.Forms.Control -> unit
Public Sub ScrollControlIntoView (activeControl As Control)

Paramètres

activeControl
Control

Contrôle enfant à faire défiler vers l’affichage.

Exemples

L’exemple de code suivant active le défilement automatique d’un formulaire, redimensionne le formulaire et garantit qu’un bouton reste visible une fois le formulaire redimensionné. L’exemple nécessite que vous ayez un FormButtonbutton2 nom sur celui-ci.

private:
   void ResizeForm()
   {
      
      // Enable auto-scrolling for the form.
      this->AutoScroll = true;
      
      // Resize the form.
      Rectangle r = this->ClientRectangle;
      
      // Subtract 100 pixels from each side of the Rectangle.
      r.Inflate(  -100, -100 );
      this->Bounds = this->RectangleToScreen( r );
      
      // Make sure button2 is visible.
      this->ScrollControlIntoView( button2 );
   }
private void ResizeForm()
{
   // Enable auto-scrolling for the form.
   this.AutoScroll = true;

   // Resize the form.
   Rectangle r = this.ClientRectangle;
   // Subtract 100 pixels from each side of the Rectangle.
   r.Inflate(-100, -100);
   this.Bounds = this.RectangleToScreen(r);

   // Make sure button2 is visible.
   this.ScrollControlIntoView(button2);
}
Private Sub ResizeForm()
   ' Enable auto-scrolling for the form.
   Me.AutoScroll = True
   
   ' Resize the form.
   Dim r As Rectangle = Me.ClientRectangle
   ' Subtract 100 pixels from each side of the Rectangle.
   r.Inflate(- 100, - 100)
   Me.Bounds = Me.RectangleToScreen(r)
   
   ' Make sure button2 is visible.
   Me.ScrollControlIntoView(button2)
End Sub

Remarques

La AutoScroll propriété doit être définie truesur , et au moins l’une des barres de défilement, horizontales ou verticales, doit également être visible, pour que la ScrollControlIntoView méthode ait un effet. Pour rendre les barres de défilement horizontales et verticales visibles, respectivement, les propriétés et VScroll les HScroll propriétés doivent être définies sur true.

Si le activeControl paramètre n’est pas un contrôle enfant, aucune action n’a lieu.

Cette méthode peut déclencher l’événement Scroll .

S’applique à

Voir aussi