Results 1 to 8 of 8

Thread: [RESOLVED] help..autosearch listview

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    13

    Resolved [RESOLVED] help..autosearch listview

    hi..
    how do I autosearch from listview.
    for example:

    when I type 'A' into the textbox, all the word that begin with 'A' will appear in the listview....

    TQ..

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: help..autosearch listview

    listview or listbox?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: help..autosearch listview

    i just whipped up a sample for a listview
    VB Code:
    1. Dim WordList() As String
    2. Private Sub Form_Load()
    3. ListView1.ListItems.Add , , "AAA"
    4. ListView1.ListItems.Add , , "AAB"
    5. ListView1.ListItems.Add , , "ABB"
    6. ListView1.ListItems.Add , , "BBA"
    7. ListView1.ListItems.Add , , "BBC"
    8. ListView1.ListItems.Add , , "DDE"
    9. ListView1.ListItems.Add , , "FFF"
    10. ListView1.ListItems.Add , , "FFG"
    11. ListView1.ListItems.Add , , "RRR"
    12. ReDim WordList(0)
    13. For x = 1 To ListView1.ListItems.Count
    14.     WordList(x - 1) = ListView1.ListItems(x).Text
    15.     If x <> ListView1.ListItems.Count Then ReDim Preserve WordList(UBound(WordList) + 1)
    16. Next
    17. End Sub
    18.  
    19.  
    20.  
    21. Private Sub Text1_Change()
    22. ListView1.ListItems.Clear
    23.     For x = 0 To UBound(WordList)
    24.         If Text1 = "" Then
    25.             ListView1.ListItems.Add , , WordList(x)
    26.         Else
    27.             If LCase(Left(WordList(x), Len(Text1))) = LCase(Text1) Then
    28.                 ListView1.ListItems.Add , , WordList(x)
    29.             End If
    30.         End If
    31.     Next
    32. End Sub

    this is with the listview set to 2-lvwList for the view setting
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: help..autosearch listview

    This looks pretty slick. I have to go to a meeting but I'm gonna bookmark this and try it out later.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    13

    Re: help..autosearch listview

    Quote Originally Posted by [A51g]Static
    i just whipped up a sample for a listview
    VB Code:
    1. Dim WordList() As String
    2. Private Sub Form_Load()
    3. ListView1.ListItems.Add , , "AAA"
    4. ListView1.ListItems.Add , , "AAB"
    5. ListView1.ListItems.Add , , "ABB"
    6. ListView1.ListItems.Add , , "BBA"
    7. ListView1.ListItems.Add , , "BBC"
    8. ListView1.ListItems.Add , , "DDE"
    9. ListView1.ListItems.Add , , "FFF"
    10. ListView1.ListItems.Add , , "FFG"
    11. ListView1.ListItems.Add , , "RRR"
    12. ReDim WordList(0)
    13. For x = 1 To ListView1.ListItems.Count
    14.     WordList(x - 1) = ListView1.ListItems(x).Text
    15.     If x <> ListView1.ListItems.Count Then ReDim Preserve WordList(UBound(WordList) + 1)
    16. Next
    17. End Sub
    18.  
    19.  
    20.  
    21. Private Sub Text1_Change()
    22. ListView1.ListItems.Clear
    23.     For x = 0 To UBound(WordList)
    24.         If Text1 = "" Then
    25.             ListView1.ListItems.Add , , WordList(x)
    26.         Else
    27.             If LCase(Left(WordList(x), Len(Text1))) = LCase(Text1) Then
    28.                 ListView1.ListItems.Add , , WordList(x)
    29.             End If
    30.         End If
    31.     Next
    32. End Sub

    this is with the listview set to 2-lvwList for the view setting
    I have few colums in both of my listview..but i just need to display some colums from the first listview to the second one..
    I am new to vb so I don't really see how I can modified your code.....

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: help..autosearch listview

    remove the stuff about the Wordlist()

    just use this:
    VB Code:
    1. Private Sub Text1_Change()
    2. ListView2.ListItems.Clear
    3.     For x = 1 To ListView1.ListItems.Count
    4.         If Text1 = "" Then
    5.             ListView2.ListItems.Add , , ListView1.ListItems(x).Text
    6.         Else
    7.             If LCase(Left(ListView1.ListItems(x).Text, Len(Text1))) = LCase(Text1) Then
    8.                 ListView2.ListItems.Add , , ListView1.ListItems(x).Text
    9.             End If
    10.         End If
    11.     Next
    12. End Sub

    you will need to add subitems as weel for each of your columns, but this should get you going ! (I hope)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    13

    Re: help..autosearch listview

    Thanks [A51g]Static..
    I already find the solution myself...its almost the same as yours


  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: help..autosearch listview

    Quote Originally Posted by yatt
    Thanks [A51g]Static..
    I already find the solution myself...its almost the same as yours

    Post your solution and share it with the rest of us.

Posting Permissions

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



Click Here to Expand Forum to Full Width