다음을 통해 공유


ScrollableControl.Scroll 이벤트

정의

사용자 또는 코드가 클라이언트 영역을 스크롤할 때 발생합니다.

public:
 event System::Windows::Forms::ScrollEventHandler ^ Scroll;
public event System.Windows.Forms.ScrollEventHandler Scroll;
public event System.Windows.Forms.ScrollEventHandler? Scroll;
member this.Scroll : System.Windows.Forms.ScrollEventHandler 
Public Custom Event Scroll As ScrollEventHandler 

이벤트 유형

예제

다음 코드 예제에서는이 멤버의 사용을 보여 줍니다. 이 예제에서 이벤트 처리기는 이벤트의 발생을 보고합니다 Scroll . 이 보고서는 이벤트가 발생하는 시기를 파악하는 데 도움이 되며 디버깅에 도움이 될 수 있습니다. 여러 이벤트 또는 자주 발생하는 이벤트에 대해 보고하려면 메시지를 여러 줄MessageBox.ShowConsole.WriteLine 대체 TextBox 하거나 추가해 보세요.

예제 코드를 실행하려면 예제 코드를 상속 ScrollableControl하는 형식의 인스턴스(예 Panel : a 또는 ContainerControl.)가 포함된 프로젝트에 붙여넣습니다. 그런 다음 인스턴스 ScrollableControl1 이름을 지정하고 이벤트 처리기가 이벤트와 연결되어 있는지 확인합니다 Scroll .

private void ScrollableControl1_Scroll(Object sender, ScrollEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ScrollOrientation", e.ScrollOrientation );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Type", e.Type );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "NewValue", e.NewValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "OldValue", e.OldValue );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Scroll Event" );
}
Private Sub ScrollableControl1_Scroll(sender as Object, e as ScrollEventArgs) _ 
     Handles ScrollableControl1.Scroll

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ScrollOrientation", e.ScrollOrientation)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Type", e.Type)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "NewValue", e.NewValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "OldValue", e.OldValue)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Scroll Event")

End Sub

설명

Scroll 이벤트는 사용자가 스크롤 막대와 상호 작용하여 클라이언트 영역을 스크롤하거나 사용자가 컨트롤 사이를 탐색하고 활성 컨트롤이 보기로 스크롤되는 경우에 발생합니다. 이 Scroll 이벤트는 클라이언트 영역을 스크롤하는 속성 설정 AutoScrollPosition 과 같은 코드를 작성할 때도 발생합니다.

이벤트 처리기의 속성을 사용하여 ScrollOrientation 이벤트의 스크롤 막대 방향을 Scroll 확인할 수 있습니다.

이벤트를 처리하는 방법에 대한 자세한 내용은 이벤트 처리 및 발생을 참조하세요.

적용 대상

추가 정보