ScrollableControl.ScrollControlIntoView(Control) Metod

Definition

Rullar den angivna underordnade kontrollen i vyn för en automatiskt rullningsaktiverad kontroll.

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)

Parametrar

activeControl
Control

Den underordnade kontrollen för att rulla in i vyn.

Exempel

Följande kodexempel möjliggör automatisk rullning för ett formulär, ändrar storlek på formuläret och ser till att en knapp förblir synlig när formuläret har storleksändrats. Exemplet kräver att du har en Form med namnet Buttonbutton2 på den.

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

Kommentarer

Egenskapen AutoScroll måste vara inställd på true, och minst en av rullningslisterna, vågräta eller lodräta, måste också vara synliga för ScrollControlIntoView att metoden ska ha en effekt. Om du vill göra de vågräta och lodräta rullningslisterna HScroll synliga måste egenskaperna och VScroll vara inställda på true.

Om parametern inte är en underordnad activeControl kontroll utförs ingen åtgärd.

Den här metoden kan generera händelsen Scroll .

Gäller för

Se även