다음을 통해 공유


ScrollableControl.AutoScrollMargin 속성

자동 스크롤 여백의 크기를 가져오거나 설정합니다.

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

구문

‘선언
<LocalizableAttribute(True)> _
Public Property AutoScrollMargin As Size
‘사용 방법
Dim instance As ScrollableControl
Dim value As Size

value = instance.AutoScrollMargin

instance.AutoScrollMargin = value
[LocalizableAttribute(true)] 
public Size AutoScrollMargin { get; set; }
[LocalizableAttribute(true)] 
public:
property Size AutoScrollMargin {
    Size get ();
    void set (Size value);
}
/** @property */
public Size get_AutoScrollMargin ()

/** @property */
public void set_AutoScrollMargin (Size value)
public function get AutoScrollMargin () : Size

public function set AutoScrollMargin (value : Size)

속성 값

자동 스크롤 여백의 높이와 너비를 픽셀 단위로 나타내는 Size입니다.

예외

예외 형식 조건

ArgumentOutOfRangeException

할당된 Height 또는 Width 값이 0보다 작은 경우

설명

자동 스크롤 여백은 자식 컨트롤과 스크롤할 수 있는 부모 컨트롤의 가장자리 사이의 간격입니다. AutoScrollMargin 크기는 스크롤 막대가 필요한지 여부를 결정하는 스크롤 가능 컨트롤에 포함된 자식 컨트롤의 크기에 추가됩니다. AutoScrollMargin 속성은 스크롤할 수 있는 부모 컨트롤의 크기가 조정되거나 개별 자식 컨트롤이 표시될 때 확인되며 스크롤 막대를 표시해야 할지 여부를 결정하는 데 사용됩니다. 스크롤 막대를 표시해야 할지 여부를 결정할 때 도킹된 컨트롤은 제외됩니다.

참고

도킹된 컨트롤의 Dock 속성이 DockStyle.Fill로 설정되면 해당 컨트롤은 스크롤할 수 있는 부모 컨트롤을 채우며 AutoScrollMargin을 사용하여 스크롤 막대가 필요한지 여부를 결정할 때 도킹된 컨트롤은 무시됩니다.

자식 컨트롤의 가장자리에서 스크롤할 수 있는 부모 컨트롤까지의 간격이 AutoScrollMargin 속성에 할당된 값보다 작고 AutoScroll 속성이 true로 설정되면 해당 스크롤 막대가 표시됩니다.

참고

스크롤할 수 있는 컨트롤 내에 컨트롤을 도킹할 때는 스크롤이 필요한 다른 모든 컨트롤을 포함할 수 있도록 Panel과 같이 스크롤할 수 있는 자식 컨트롤을 추가하는 것이 좋습니다. 스크롤할 수 있는 컨트롤에 자식 Panel 컨트롤을 추가하고 이 컨트롤의 Dock 속성은 DockStyle.Fill로, AutoScroll 속성은 true로 설정해야 합니다. 스크롤할 수 있는 부모 컨트롤의 AutoScroll 속성은 false로 설정해야 합니다.

예제

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

Private Sub SetAutoScrollMargins()
    ' 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 SetAutoScrollMargins()
 {
    /* 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 SetAutoScrollMargins()
{
   /* 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 SetAutoScrollMargins()
{
    /* 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);
        }
    }
} //SetAutoScrollMargins

플랫폼

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에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

ScrollableControl 클래스
ScrollableControl 멤버
System.Windows.Forms 네임스페이스
ScrollableControl.AutoScroll 속성
SetAutoScrollMargin
AutoScrollPosition
AutoScrollMinSize
DisplayRectangle