Results 1 to 3 of 3
  1. #1
    NeRd.?'s Avatar
    Join Date
    Apr 2012
    Gender
    male
    Posts
    47
    Reputation
    10
    Thanks
    0
    My Mood
    Tired

    [Help]ListView Searching

    Hello guys!

    I have this code:

    Code:
    ListView1.MultiSelect = True
            ListView1.SelectedItems.Clear()
                Dim itm As ListViewItem
    
                With ListView1
                    itm = .FindItemWithText(TextBox4.Text, True, 0, True)
                    If Not itm Is Nothing Then
    
                        For i = 0 To ListView1.Items.Count - 1
                            .Items.Item(itm.Index).Selected = True
                        Next i
    
                        itm = Nothing
    
                    End If
                End With
    but this code only select one item. I want to make code which will select multiply items!


    Thanks for help!

  2. #2
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    Are you trying to select everything in listview?
    Quote Originally Posted by NeRd.? View Post
    Hello guys!

    I have this code:

    Code:
    ListView1.MultiSelect = True
            ListView1.SelectedItems.Clear()
                Dim itm As ListViewItem
    
                With ListView1
                    itm = .FindItemWithText(TextBox4.Text, True, 0, True)
                    If Not itm Is Nothing Then
    
                        For i = 0 To ListView1.Items.Count - 1
                            .Items.Item(itm.Index).Selected = True
                        Next i
    
                        itm = Nothing
    
                    End If
                End With
    but this code only select one item. I want to make code which will select multiply items!


    Thanks for help!

  3. #3
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    There is a logic problem on that code, index is a unique property. As far as I can see, you are only getting one index from the first item you find that has the text from the textbox.

    So its pointless to select every items with that index because there is only ONE for sure. (useless FOR, its repeating exactly the same every single loop)

    New Logic:

    Code:
    Loop
          Check If the current item has the text you want
                   If yes, select
    Dont forget about the multiselect property of the control
    Last edited by 'Bruno; 07-18-2012 at 10:51 PM.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

Similar Threads

  1. [Help]Treeview Search Button[Solved]
    By ModelCookie2 in forum Visual Basic Programming
    Replies: 6
    Last Post: 10-30-2010, 11:52 AM
  2. [Reqest] help to search more features
    By GER-Domi. in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 4
    Last Post: 09-24-2010, 02:50 PM
  3. [Help]notepad search function
    By mizzer3 in forum Visual Basic Programming
    Replies: 30
    Last Post: 09-10-2010, 01:10 PM
  4. [Help]Listview[Solved]
    By Blubb1337 in forum Visual Basic Programming
    Replies: 19
    Last Post: 03-31-2010, 03:53 PM
  5. help i search a new combat arms hack -.-
    By maik090 in forum Combat Arms Hacks & Cheats
    Replies: 1
    Last Post: 05-01-2009, 07:24 AM