ScrollableControl.AutoScrollPosition 속성

정의

자동 스크롤 위치를 가져오거나 설정합니다.

public:
 property System::Drawing::Point AutoScrollPosition { System::Drawing::Point get(); void set(System::Drawing::Point value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point AutoScrollPosition { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.AutoScrollPosition : System.Drawing.Point with get, set
Public Property AutoScrollPosition As Point

속성 값

자동 스크롤 위치를 픽셀 단위로 나타내는 Point입니다.

특성

예제

다음 코드 예제에서는 파생 클래스 PanelScrollableControl 사용하고 스크롤 가능 영역의 왼쪽 위 모서리에 단추를 추가합니다. 이 예제에서는 에 의해 결정되는 오프셋을 허용합니다 AutoScrollPosition. 이 예제는 에 가 포함된 가 있다는 PanelButton 가정 Form 하에 작성되었습니다. 자동 스크롤을 사용하도록 설정하려면 단추를 의 클라이언트 영역 외부에 배치합니다 Panel.

private:
   void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      /* Add a button to top left corner of the
            * scrollable area, allowing for the offset. */
      panel1->AutoScroll = true;
      Button^ myButton = gcnew Button;
      myButton->Location = Point(0 + panel1->AutoScrollPosition.X,0 + panel1->AutoScrollPosition.Y);
      panel1->Controls->Add( myButton );
   }
private void button1_Click(object sender, EventArgs e)
{
   /* Add a button to top left corner of the 
    * scrollable area, allowing for the offset. */
   panel1.AutoScroll = true;
   Button myButton = new Button();
   myButton.Location = new Point(
      0 + panel1.AutoScrollPosition.X, 
      0 + panel1.AutoScrollPosition.Y);
   panel1.Controls.Add(myButton);
}
Private Sub button1_Click(sender As Object, _
   e As EventArgs) Handles button1.Click
   ' Add a button to top left corner of the 
   ' scrollable area, allowing for the offset. 
   panel1.AutoScroll = True
   Dim myButton As New Button()
   myButton.Location = New Point( _
      0 + panel1.AutoScrollPosition.X, _
      0 + panel1.AutoScrollPosition.Y)
   panel1.Controls.Add(myButton)
End Sub

설명

속성은 AutoScrollPosition 스크롤 가능한 컨트롤의 표시되는 부분의 위치를 나타냅니다. 표시 되는 컨트롤의 부분을 변경 하려면이 속성을 사용 합니다.

폼에 프로그래밍 방식으로 컨트롤을 추가할 때 사용 된 AutoScrollPosition 현재 볼 수 있는 스크롤 영역의 내부 또는 외부에 컨트롤을 배치 하는 속성입니다.

참고

X 검색된 및 Y 좌표 값은 컨트롤이 시작 위치(0,0)에서 멀리 스크롤된 경우 음수입니다. 이 속성을 설정할 때 항상 양 X 수 및 Y 값을 할당하여 시작 위치를 기준으로 스크롤 위치를 설정해야 합니다. 예를 들어 가로 스크롤 막대가 있고 x와 y를 200으로 설정하면 스크롤 200픽셀을 오른쪽으로 이동합니다. x와 y를 100으로 설정하면 시작 위치에서 100픽셀 떨어진 위치로 설정하므로 스크롤이 왼쪽으로 100픽셀씩 점프하는 것처럼 보입니다. 첫 번째 경우 AutoScrollPosition 는 {-200, 0}을 반환하고, 두 번째 경우에는 를 반환합니다 {-100,0}.

변경 시기를 AutoScrollPosition 감지하려면 이벤트에 대한 Paint 이벤트 처리기를 만들고, 이전 위치 값을 프라이빗 변수에 저장하고, 새 값을 후속 Paint 이벤트의 이전 값과 비교합니다.

적용 대상

추가 정보