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합니다. 이 예제에서는 텍스트 상자의 위치를 평가하고 부모 컨테이너인 패널 컨트롤의 모양과 동작을 변경합니다. 이 예제에서는 컨트롤TextBoxPanel 인스턴스를 만들어야 합니다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

설명

여백은 각 컨트롤 주위의 테두리 너비와 높이를 설정합니다. 이 여백은 컨테이너에서 스크롤 막대가 필요한 시기와 컨트롤을 선택할 때 스크롤할 위치를 결정하는 데 사용됩니다.

참고

음수가 또는 y 값으로 전달되면 값이 0으로 x 다시 설정됩니다.

적용 대상

추가 정보