Share via


ScrollableControl.ScrollControlIntoView(Control) Metode

Definisi

Menggulir kontrol anak yang ditentukan ke tampilan pada kontrol yang diaktifkan gulir otomatis.

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)

Parameter

activeControl
Control

Kontrol anak untuk menggulir ke tampilan.

Contoh

Contoh kode berikut memungkinkan pengguliran otomatis untuk formulir, mengubah ukuran formulir, dan memastikan bahwa tombol tetap terlihat setelah formulir diubah ukurannya. Contohnya mengharuskan Anda memiliki Form dengan nama Buttonbutton2 di dalamnya.

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

Keterangan

Properti AutoScroll harus diatur ke true, dan setidaknya salah satu bilah gulir, horizontal atau vertikal, juga harus terlihat, ScrollControlIntoView agar metode memiliki efek. Untuk membuat bilah gulir horizontal dan vertikal terlihat, HScroll properti dan VScroll , masing-masing harus diatur ke true.

activeControl Jika parameter bukan kontrol anak, tidak ada tindakan yang terjadi.

Metode ini dapat meningkatkan Scroll peristiwa.

Berlaku untuk

Lihat juga