ScrollableControl.ScrollControlIntoView(Control) Metoda

Definicja

Przewija określoną kontrolkę podrzędną do widoku w kontrolce z włączonym automatycznym przewijaniem.

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)

Parametry

activeControl
Control

Kontrolka podrzędna do przewijania do widoku.

Przykłady

Poniższy przykład kodu umożliwia automatyczne przewijanie formularza, zmienia rozmiar formularza i zapewnia, że przycisk pozostaje widoczny po zmianie rozmiaru formularza. W tym przykładzie jest wymagany Form element z nazwanym button2 elementem Button .

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

Uwagi

Właściwość AutoScroll musi być ustawiona na true, a co najmniej jeden z pasków przewijania, poziomy lub pionowy, musi być również widoczny, aby ScrollControlIntoView metoda miała efekt. Aby ustawić poziome i pionowe paski przewijania, HScroll odpowiednio właściwości i VScroll muszą być ustawione na true.

activeControl Jeśli parametr nie jest kontrolką podrzędną, nie ma żadnej akcji.

Ta metoda może zgłosić Scroll zdarzenie.

Dotyczy

Zobacz też