ScrollEventHandler Delegate
Represents the method that handles the Scroll event of a DataGridView, ScrollBar, TrackBar, or DataGrid.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
'Declaration Public Delegate Sub ScrollEventHandler ( _ sender As Object, _ e As ScrollEventArgs _ ) 'Usage Dim instance As New ScrollEventHandler(AddressOf HandlerMethod)
Parameters
- sender
- Type: System.Object
The source of the event.
- e
- Type: System.Windows.Forms.ScrollEventArgs
A ScrollEventArgs that contains the event data.
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 Events and Delegates.
The following code example demonstrates the use of this type.
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
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.