guys i have an issue with scrolling a datagridview (VB.Net 2010) using the mouse wheel
i created a mousewheel event an i am catching the mouse-wheel movement up or down
i created a scroll event and set the boundaries for the scroll, but i have no idea how to combine both procedures:
Mouse wheel event
Public Sub grdMouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim RowIndex As Integer = grdAccountTypes.CurrentRow.Index
If e.Delta < 0 Then
MessageBox.Show("Mouse wheel is being moved down")
Else
'RowIndex = grdAccountTypes.CurrentRow.Index + 1
'RowIndex = grdAccountTypes.FirstDisplayedScrollingRowIndex Then
' grdAccountTypes(0, 0).Selected = True
MessageBox.Show("Mouse wheel is being moved up")
End If
Scroll Event
Public Sub grdScroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs)
Dim RowIndex As Integer = grdAccountTypes.CurrentRow.Index + e.NewValue
If grdAccountTypes.RowCount = 0 Then ' if no row exist right now
MessageBox.Show("No row existed right now. Please add some records")
ElseIf RowIndex = grdAccountTypes.Rows.Count() - 1 Then
grdAccountTypes(0, 0).Selected = True
Else
grdAccountTypes(0, RowIndex).Selected = True
End If
End Sub
any help would be appreciated