ScrollableControl.ScrollControlIntoView(Control) ScrollableControl.ScrollControlIntoView(Control) ScrollableControl.ScrollControlIntoView(Control) ScrollableControl.ScrollControlIntoView(Control) Method

定義

將指定的子控制項捲動至已啟用自動捲動之控制項的檢視中。Scrolls the specified child control into view on an auto-scroll enabled control.

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)

參數

activeControl
Control Control Control Control

要捲動至檢視中的子控制項。The child control to scroll into view.

範例

下列程式碼範例會針對表單啟用自動滾動、調整表單的大小,並確保按鈕在調整大小後仍然可見。The following code example enables auto-scrolling for a form, resizes the form, and ensures that a button remains visible after the form is resized. 此範例會要求您在其Form上具有Buttonbutton2為的。The example requires that you have a Form with a Button named button2 on it.

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

備註

屬性必須設定為true,而且至少有一個捲軸(水準或垂直)也必須為可見ScrollControlIntoView ,方法才會有效果。 AutoScrollThe AutoScroll property must be set to true, and at least one of the scroll bars, horizontal or vertical, must also be visible, for the ScrollControlIntoView method to have an effect. 若要顯示水準和垂直捲動條,則HScrollVScroll屬性分別必須設定為trueTo make the horizontal and vertical scroll bars visible, the HScroll and VScroll properties, respectively, must be set to true.

activeControl如果參數不是子控制項,就不會執行任何動作。If the activeControl parameter is not a child control, no action takes place.

這個方法可能會引發Scroll事件。This method may raise the Scroll event.

適用於

另請參閱