listView .findItem when duplicates exist (Performance Issue the way it is coded)
I have a listview that contains a checkbox, Div, UserID. I am using this to make a txt file of all the ones that are checked. The problem is that the listview contains around 100,000 entries which already takes about 7 seconds to load and I need to take the entries from the text file that are saved Div~UserID and search through the listview and check the ones that are already in the file.
Here is how I am doing it now
For j = 0 To intCounter - 1
For i = 1 To .ListItems.Count
.SelectedItem = .ListItems.Item(i)
If .SelectedItem.ListSubItems(1) & "~" & .SelectedItem.ListSubItems(2) = varArray(j) Then
.SelectedItem.Checked = True
i = .ListItems.Count
This is extremly slow being that it has to go through the entire listview until it finds the correct one.
I was wanting to use the .finditem method but cant seem to get it to work when there are duplicates. It always just selects the first one and that is it. I did notice object.FindItem (string, value, index, match) and that index can supposly by a key. When I am loading the list I make the Key = Div~UserID but when I try to set the index = to that string for the key it gives a type mismatch. Even though it says the string is the value of the Key property for what the index is.
Any ideas to help speed up performance?
The FindItem method works on the Text, or any SubItem, or the Tag property.
I would assign the Tag property to Div~UserID, and then loop through (code not tested)
dim index as long
index = 1
set it = .FindItem(stringToFind, lvwTag, index)
if it is nothing then exit do
---- do something with it here
index = it.index + 1 '' start again from the next item
set it = nothing
"There are two ways to write error-free programs. Only the third one works."
By Thomas Eyde in forum .NET
Last Post: 12-22-2001, 03:13 PM
By NewToSQL in forum VB Classic
Last Post: 01-22-2001, 02:12 PM
Last Post: 06-07-2000, 01:05 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center