Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    59

    Unanswered: Search ListView Subitems

    Hi All!

    You've all helped me track down the code I needed to Search a ListView that I have... Now I need to modify the request slightly. I need to be able to search the SubItems of a ListView for a particular item.

    I need to find a strings value (sID) in the 4th column of my data, making it SubItem(3).

    I know I've used, frmViewOnCall.ListView1.FindItem(sID), to find an item previously, but this doesn't seem to work.

    Any ideas on syntax for finding subitem 3 in Listview 1 on form "frmViewOnCall"?

    The end result, I want to find each item in the listview (with matching subitem three from what was selected earlier in the form), and remove them from the list.

    So if the user selects "test", all items in Listview1 with Subitem 3 = test will be removed :-).

    Thanks!
    Last edited by mateo107; 01-23-05 at 10:07.
    -Matt H-
    www.comperfection.com

  2. #2
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    hi,
    I assumed that you have set text properties of eache item...
    then put this code in your procedure.. Lv =name of the listview


    Dim itmFound As ListItem
    Set itmFound = F.lV.FindItem(Lv.ListItems (Lv.SelectedItem.Index).SubItems(1), 1, , lvwWholeWord)
    If itmFound Is Nothing Then
    ' Ant statement here...
    '*******
    Else
    ' Ant statement here...
    '**************
    End If

  3. #3
    Join Date
    Feb 2004
    Posts
    59

    tryin' it

    hi

    thanks for the post, i've been busy like crazy 'round here, but am going to try tonight and i'll repost and let ya know!
    -Matt H-
    www.comperfection.com

  4. #4
    Join Date
    Feb 2004
    Posts
    59
    i tried this method, and i'm getting closer but still getting an error, here's the code i've used, but I get a "type mismatch" error...

    set itmFound = ListView1.FindItem(ListView1.ListItems(ListView1.S electedItem.Index).SubItems(3), sID, , lvwWholeWord)

    where: ListView1 is the name of my Listview, sID is my search string, and '3' is the column where i'm searching for matching sID (already set).

    When the program runs, and I search for (for example) sID = "HSD". I get the type-mismatch error, but I can hold my mouse over the code, and see that I'm correctly searching for "HSD", and that the currentListview item is "ATM". So if they've both in quotes, why the type-mistmatch?

    Thanks!
    Last edited by mateo107; 01-29-05 at 12:02.
    -Matt H-
    www.comperfection.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •