issue has to do with the number of rows which I represent
The first row in the dB is 0, so to prevent confusions I added 1 to the index so row 0 will be represented as row 1. The issue is that when I scroll down I “gain” a row, and the last row will be presented as row 23, though I actually have only 22 records.

Public Sub grdMouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs)
        Try

            If e.Delta > 0 Then
                Dim index As Integer
                index = grdAccountTypes.CurrentRow.Index + 1

                grdAccountTypes.DataSource.moveprevious()
                grdAccountTypes.Select()


                lblCRM.Text = index.ToString

            ElseIf (e.Delta < 0) Then
                Dim index As Integer
                index = grdAccountTypes.CurrentRow.Index + 1 + 1
                grdAccountTypes.Select()
                grdAccountTypes.DataSource.MoveNext()

                lblCRM.Text = index.ToString
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Recommended Answers

All 2 Replies

hi eladreznik

I think maybe index should be CurrentRow.Index + 1 irrespective of e.delta. This line is causing the problem:

index = grdAccountTypes.CurrentRow.Index + 1 + 1

iunderstand that however if i will not assign that value to index then the first row index would be 0 and not 1 and it's kind of confusing

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.