ScrollEventHandler ScrollEventHandler ScrollEventHandler ScrollEventHandler Delegate

정의

DataGridView, ScrollBar, TrackBar 또는 DataGridScroll 이벤트를 처리하는 메서드를 나타냅니다.Represents the method that handles the Scroll event of a DataGridView, ScrollBar, TrackBar, or DataGrid.

public delegate void ScrollEventHandler(System::Object ^ sender, ScrollEventArgs ^ e);
public delegate void ScrollEventHandler(object sender, ScrollEventArgs e);
type ScrollEventHandler = delegate of obj * ScrollEventArgs -> unit
Public Delegate Sub ScrollEventHandler(sender As Object, e As ScrollEventArgs)

매개 변수

sender
Object Object Object Object

이벤트 소스입니다.The source of the event.

e
ScrollEventArgs ScrollEventArgs ScrollEventArgs ScrollEventArgs

이벤트 데이터를 포함하는 ScrollEventArgs입니다.A ScrollEventArgs that contains the event data.

상속
ScrollEventHandlerScrollEventHandlerScrollEventHandlerScrollEventHandler

예제

다음 코드 예제에서는이 형식 사용 하는 방법을 보여 줍니다.The following code example demonstrates the use of this type.

void AddMyScrollEventHandlers()
{
   // Create and initialize a VScrollBar.
   VScrollBar^ vScrollBar1 = gcnew VScrollBar;

   // Add event handlers for the OnScroll and OnValueChanged events.
   vScrollBar1->Scroll += gcnew ScrollEventHandler( this, &Form1::vScrollBar1_Scroll );
   vScrollBar1->ValueChanged += gcnew EventHandler( this, &Form1::vScrollBar1_ValueChanged );
}

// Create the ValueChanged event handler.
void vScrollBar1_ValueChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // Display the new value in the label.
   label1->Text = String::Format( "vScrollBar Value:(OnValueChanged Event) {0}", vScrollBar1->Value );
}

// Create the Scroll event handler.
void vScrollBar1_Scroll( Object^ /*sender*/, ScrollEventArgs^ e )
{
   // Display the new value in the label.
   label1->Text = String::Format( "VScrollBar Value:(OnScroll Event) {0}", e->NewValue );
}

void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // Add 40 to the Value property if it will not exceed the Maximum value.
   if ( vScrollBar1->Value + 40 < vScrollBar1->Maximum )
   {
      vScrollBar1->Value = vScrollBar1->Value + 40;
   }
}
private void AddMyScrollEventHandlers()
 {
    // Create and initialize a VScrollBar.
    VScrollBar vScrollBar1 = new VScrollBar();
 
    // Add event handlers for the OnScroll and OnValueChanged events.
    vScrollBar1.Scroll += new ScrollEventHandler(
       this.vScrollBar1_Scroll);
    vScrollBar1.ValueChanged += new EventHandler(
       this.vScrollBar1_ValueChanged); 
 }
 
 // Create the ValueChanged event handler.
 private void vScrollBar1_ValueChanged(Object sender, 
                                       EventArgs e)
 {
     // Display the new value in the label.
     label1.Text = "vScrollBar Value:(OnValueChanged Event) " + vScrollBar1.Value.ToString();
 }
 
 // Create the Scroll event handler.
 private void vScrollBar1_Scroll(Object sender, 
                                 ScrollEventArgs e)
 {
     // Display the new value in the label.
     label1.Text = "VScrollBar Value:(OnScroll Event) " + e.NewValue.ToString();
 }
 
 private void button1_Click(Object sender, 
                           EventArgs e)
 {
    // Add 40 to the Value property if it will not exceed the Maximum value.
    if (vScrollBar1.Value + 40 < vScrollBar1.Maximum)
    {
        vScrollBar1.Value = vScrollBar1.Value + 40;
    }
 }
 
Private Sub AddMyScrollEventHandlers()
    ' Create and initialize a VScrollBar.
    Dim vScrollBar1 As New VScrollBar()
    
    ' Add event handlers for the OnScroll and OnValueChanged events.
    AddHandler vScrollBar1.Scroll, AddressOf Me.vScrollBar1_Scroll
    AddHandler vScrollBar1.ValueChanged, AddressOf Me.vScrollBar1_ValueChanged
End Sub    

' Create the ValueChanged event handler.
Private Sub vScrollBar1_ValueChanged(sender As Object, e As EventArgs)
    ' Display the new value in the label.
    label1.Text = "vScrollBar Value:(OnValueChanged Event) " & _
        vScrollBar1.Value.ToString()
End Sub    

' Create the Scroll event handler.
Private Sub vScrollBar1_Scroll(sender As Object, e As ScrollEventArgs)
    ' Display the new value in the label.
    label1.Text = "VScrollBar Value:(OnScroll Event) " & _
        e.NewValue.ToString()
End Sub    

Private Sub button1_Click(sender As Object, e As EventArgs)
    ' Add 40 to the Value property if it will not exceed the Maximum value.
    If vScrollBar1.Value + 40 < vScrollBar1.Maximum Then
        vScrollBar1.Value = vScrollBar1.Value + 40
    End If
End Sub

설명

ScrollEventArgs 대리자를 만들 때, 이벤트를 처리할 메서드를 식별합니다.When you create a ScrollEventArgs delegate, you identify the method that will handle the event. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다.To associate the event with your event handler, add an instance of the delegate to the event. 대리자를 제거하지 않는 경우 이벤트가 발생할 때마다 이벤트 처리기가 호출됩니다.The event handler is called whenever the event occurs, unless you remove the delegate. 이벤트 처리기 대리자에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.For more information about event handler delegates, see Handling and Raising Events.

확장 메서드

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.Gets an object that represents the method represented by the specified delegate.

적용 대상

추가 정보