ScrollableControl.SetAutoScrollMargin(Int32, Int32) Метод

Определение

Задает размер полей автоматической прокрутки.

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)

Параметры

x
Int32

Значение Width.

y
Int32

Значение Height.

Примеры

В следующем примере кода используется производный класс Panel. В примере оценивается расположение текстового поля и изменяется внешний вид и поведение родительского контейнера, элемент управления панелью. В этом примере требуется, чтобы вы создали экземпляр Panel элемента управления, TextBoxи Button. Поместите поле на панель, чтобы она перекрывала по крайней мере одну из краев панели. Вызовите эту подпросезону на нажатии кнопки, чтобы увидеть разницу в поведении и внешнем виде панели.

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

Комментарии

Поле задает ширину и высоту границы вокруг каждого элемента управления. Это поле используется для определения необходимости полос прокрутки в контейнере и места прокрутки до выбранного элемента управления.

Note

Если отрицательное число передается в виде или x значенийy, значение будет сброшено до 0.

Применяется к

См. также раздел