How do I get the start index and number of visible items in a ListView?

前端 未结 7 1964
迷失自我
迷失自我 2020-12-21 02:37

I have a listview working in virtual mode, in the LargeIcons view. Retrieves are expensive, so I want to ask for the data for all the visible items. How do I get the start

7条回答
  •  心在旅途
    2020-12-21 03:26

    Try this:

    If ListView.Items.Count > 0 Then
        Dim lvi As ListViewItem = ListView.TopItem
        If lvi Is Nothing Then Return
        Dim startIndex As Integer = lvi.Index
        Dim lastVisible As Integer = startIndex
        While ListView.Items(lastVisible).Bounds.Bottom < Me.lvRes.Bounds.Bottom
            lastVisible += 1
        End While
        lastVisible -= 1
    End If
    

提交回复
热议问题