Question ListView Navigation

tqmd1

Well-known member
Joined
Dec 5, 2009
Messages
60
Programming Experience
Beginner
Dear Experts

Following codes work fine to go t next record record in Listview.
What will be the codes to go previous record.
Please modify


VB.NET:
Private Sub MoveNext()
        If (ListView1.Items.Count = 0) Then
            'Nothing to  selected
        ElseIf (ListView1.SelectedItems.Count = 0) Then
            'Nothing selected, select the first
            ListView1.Items(0).Selected = True
        Else

            Dim idx As Integer
            If (ListView1.Items.Count - 1 > ListView1.SelectedIndices(0)) Then
                idx = ListView1.SelectedIndices(0) + 1 'Select the next item
            Else
                idx = 0 'We're at the end, start at the beginning
            End If
            ListView1.SelectedItems.Clear()
            ListView1.Items(idx).Selected = True
        End If
    End Sub
 
Back
Top