Search Tools Links Login

Fast ListView Clear Function

Posted: 2003-06-01
By: ArchiveBot
Viewed: 86

Filed Under:

Visual Basic 6

No attachments for this post

The ListView's clear method becomes slow on large lists. This function removes items faster.

Original Author: David Peake


ListView Control


You've got VB!


Public Sub ListView_Clear(lstListName As ListView)
Dim lCount As Long
Dim lLoop As Long
' Count items in listview
lCount = lstListName.ListItems.Count
' clear would probably be faster on a low number!
If lCount > 10 Then
  ' loop through (backwards) to remove items
  ' They're not visible so it's becomes fatser!!
  For lLoop = lCount To 1 Step -1
    lstListName.ListItems.Remove lLoop
End If

End Sub

Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.