다음을 통해 공유


ScrollableControl.SetAutoScrollMargin 메서드

자동 스크롤 여백의 크기를 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Sub SetAutoScrollMargin ( _
    x As Integer, _
    y As Integer _
)
‘사용 방법
Dim instance As ScrollableControl
Dim x As Integer
Dim y As Integer

instance.SetAutoScrollMargin(x, y)
public void SetAutoScrollMargin (
    int x,
    int y
)
public:
void SetAutoScrollMargin (
    int x, 
    int y
)
public void SetAutoScrollMargin (
    int x, 
    int y
)
public function SetAutoScrollMargin (
    x : int, 
    y : int
)

매개 변수

설명

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

참고

x 또는 y 값으로 음수가 전달된 경우에는 값이 0으로 다시 설정됩니다.

예제

다음 코드 예제에서는 파생 클래스인 Panel을 사용합니다. 이 예제에서는 텍스트 상자의 위치를 계산하고 텍스트 상자의 부모 컨테이너인 Panel 컨트롤의 모양 및 동작을 변경합니다. 이 예제를 실행하려면 먼저 Panel, TextBoxButton 컨트롤의 인스턴스를 만들어야 합니다. 해당 상자가 패널의 가장자리 중 하나 이상과 겹치도록 패널에 텍스트 상자를 배치합니다. 패널 동작 및 모양의 차이점을 보려면 단추를 클릭하여 이 sub 프로시저를 호출합니다.

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
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);
       }
    }
 }
 
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.get_Location().get_X() > panel1.get_Location().get_X() 
        || text1.get_Location().get_Y() > panel1.get_Location().get_Y()) {
            panel1.set_AutoScroll(true);

        /* If the AutoScrollMargin is set to 
           less than (5,5), set it to 5,5. 
         */
        if (panel1.get_AutoScrollMargin().get_Width() < 5 
            || panel1.get_AutoScrollMargin().get_Height() < 5) {
                panel1.SetAutoScrollMargin(5, 5);
        }
    }
} //MySub

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

ScrollableControl 클래스
ScrollableControl 멤버
System.Windows.Forms 네임스페이스
AutoScrollMargin
AutoScroll
AutoScrollMinSize