Question Listview TopItem Alternatives with Groups

Semola

Member
Joined
Aug 27, 2018
Messages
6
Programming Experience
3-5
Hi all,

In a function called up the PageUP and PageDown keys, in the presence of a grouping, I need to scroll the items of a listview positioning the first item of the group as the first element of the listview.
I saw that the "TopItem" property works only in the absence of groups. I tried this code


        If e.KeyCode <> Keys.PageUp AndAlso e.KeyCode <> Keys.PageDown Then Return


        Dim groups = lvFilmDetail.Groups
        Dim groupCount = groups.Count
        Dim group = lvFilmDetail.FocusedItem.Group
        Dim groupIndex = groups.IndexOf(group)


        Select Case e.KeyCode
            Case Keys.PageUp
                groupIndex -= 1


                If groupIndex < 0 Then
                    groupIndex = groupCount - 1
                End If
            Case Keys.PageDown
                groupIndex += 1


                If groupIndex = groupCount Then
                    groupIndex = 0
                End If
        End Select


        group = groups(groupIndex)


        Dim item = group.Items(0)


        lvFilmDetail.FocusedItem = item
        lvFilmDetail.EnsureVisible(item.Index)


        e.SuppressKeyPress = True
       



but the visible item is positioned at the bottom of the listview and not at the top.

Do you have any idea to get this result?

Thanks

Semola
 
Top Bottom