ScrollableControl.AutoScrollMargin 속성

정의

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

public:
 property System::Drawing::Size AutoScrollMargin { System::Drawing::Size get(); void set(System::Drawing::Size value); };
public System.Drawing.Size AutoScrollMargin { get; set; }
member this.AutoScrollMargin : System.Drawing.Size with get, set
Public Property AutoScrollMargin As Size

속성 값

Size

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

예외

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

예제

다음 코드 예제에서는 파생된 클래스인 Panel합니다. 이 예제에서는 텍스트 상자의 위치를 평가하고 부모 컨테이너인 패널 컨트롤의 모양과 동작을 변경합니다. 이 예제에서는 컨트롤TextBoxPanel 인스턴스를 만들어야 합니다Button. 패널의 가장자리 중 하나 이상과 겹치도록 텍스트 상자를 패널에 놓습니다. 단추를 클릭할 때 이 함수를 호출하여 패널의 동작과 모양 차이를 확인합니다.

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.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 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

설명

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

참고

도킹된 컨트롤의 Dock 속성이 설정된 DockStyle.Fill경우 컨트롤은 부모 스크롤 가능 컨트롤을 채우고 스크롤 막대가 필요한지 여부를 결정하는 데 사용할 AutoScrollMargin 때 도킹된 컨트롤이 무시됩니다.

자식 컨트롤의 가장자리에서 부모 스크롤 가능 컨트롤까지의 거리가 속성에 AutoScrollMargin 할당된 값보다 작고 AutoScroll 속성이 설정 true되면 적절한 스크롤 막대가 표시됩니다.

참고

스크롤 가능한 컨트롤 내에서 컨트롤을 도킹할 때 스크롤이 필요할 수 있는 다른 컨트롤을 포함하도록 자식 스크롤 가능 컨트롤(예: Panel)을 추가하는 것이 좋습니다. 스크롤 가능한 컨트롤에 자식 Panel 컨트롤을 추가하고 해당 속성이 설정 DockStyle.Fill 되고 해당 Dock 속성이 AutoScroll .로 설정되어야 합니다true. 부모 스크롤 가능 컨트롤false의 속성을 .로 설정 AutoScroll 해야 합니다.

적용 대상

추가 정보