DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006

    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
    End If

    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?

  2. #2
    Join Date
    Nov 2003
    Alameda, CA
    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."

Similar Threads

  1. They created J#, why couldn't they do VB#?
    By Thomas Eyde in forum .NET
    Replies: 290
    Last Post: 12-22-2001, 02:13 PM
  2. Performance issue
    By NewToSQL in forum VB Classic
    Replies: 1
    Last Post: 01-22-2001, 01:12 PM
  3. Replies: 2
    Last Post: 06-07-2000, 12:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center