ScrollableControl.SetAutoScrollMargin(Int32, Int32) Metode

Definisi

Mengatur ukuran margin gulir otomatis.

public:
 void SetAutoScrollMargin(int x, int y);
public void SetAutoScrollMargin(int x, int y);
member this.SetAutoScrollMargin : int * int -> unit
Public Sub SetAutoScrollMargin (x As Integer, y As Integer)

Parameter

x
Int32

Nilai Width.

y
Int32

Nilai Height.

Contoh

Contoh kode berikut menggunakan kelas turunan, Panel. Contoh mengevaluasi lokasi kotak teks dan mengubah tampilan dan perilaku kontainer induknya, kontrol panel. Contoh mengharuskan Anda telah membuat instans Panel kontrol, TextBox, dan Button. Letakkan kotak pada panel sehingga tumpang tindih setidaknya salah satu tepi panel. Panggil subprosedur ini pada klik tombol untuk melihat perbedaan perilaku dan tampilan panel.

void MySub()
{
   /* If the text box is outside the panel's bounds, 
          turn on auto-scrolling and set the margin. */
   if ( text1->Location.X > panel1->Location.X || text1->Location.Y > panel1->Location.Y )
   {
      panel1->AutoScroll = true;

      /* If the AutoScrollMargin is set to 
                less than (5,5), set it to 5,5. */
      if ( panel1->AutoScrollMargin.Width < 5 || panel1->AutoScrollMargin.Height < 5 )
      {
         panel1->SetAutoScrollMargin( 5, 5 );
      }
   }
}
private void MySub()
 {
    /* If the text box is outside the panel's bounds, 
       turn on auto-scrolling and set the margin. */
    if (text1.Location.X > panel1.Location.X ||
     text1.Location.Y > panel1.Location.Y)
    {
       panel1.AutoScroll = true;
       /* If the AutoScrollMargin is set to 
          less than (5,5), set it to 5,5. */
       if(panel1.AutoScrollMargin.Width < 5 ||
        panel1.AutoScrollMargin.Height < 5)
       {
          panel1.SetAutoScrollMargin(5, 5);
       }
    }
 }
Private Sub MySub()
    ' If the text box is outside the panel's bounds,
    ' turn on auto-scrolling and set the margin. 
    If (text1.Location.X > panel1.Location.X) Or _
        (text1.Location.Y > panel1.Location.Y) Then
        
        panel1.AutoScroll = True            
        ' If the AutoScrollMargin is set to
        ' less than (5,5), set it to 5,5. 
        If (panel1.AutoScrollMargin.Width < 5) Or _
            (panel1.AutoScrollMargin.Height < 5) Then
            
            panel1.SetAutoScrollMargin(5, 5)
        End If
    End If
End Sub

Keterangan

Margin mengatur lebar dan tinggi batas di sekitar setiap kontrol. Margin ini digunakan untuk menentukan kapan bilah gulir diperlukan pada kontainer dan tempat untuk menggulir ke saat kontrol dipilih.

Note

Jika angka negatif diteruskan sebagai x nilai atau y , nilai akan diatur ulang ke 0.

Berlaku untuk

Lihat juga