Listview Search - Partial Search Only Needed
-
Using the code below, I can only do an EXACT seearch for an item in a listview control; however, I'd also like to do a PARTIAL search as well but can't get that working from what I can find. I know there is a FindNearestItems method, but no luck in getting that to work. Any suggestions on how to code the partial search? Here is my code that works well in a doing an EXACT search: Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged Dim Itm As ListViewItem = lstItems.FindItemWithText(txtSearch.Text, True, 0, False) If Not (Itm Is Nothing) Then lstItems.Items(Itm.Index).Selected = True lstItems.EnsureVisible(Itm.Index) lstItems.Focus() End If End Sub
-
Using the code below, I can only do an EXACT seearch for an item in a listview control; however, I'd also like to do a PARTIAL search as well but can't get that working from what I can find. I know there is a FindNearestItems method, but no luck in getting that to work. Any suggestions on how to code the partial search? Here is my code that works well in a doing an EXACT search: Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged Dim Itm As ListViewItem = lstItems.FindItemWithText(txtSearch.Text, True, 0, False) If Not (Itm Is Nothing) Then lstItems.Items(Itm.Index).Selected = True lstItems.EnsureVisible(Itm.Index) lstItems.Focus() End If End Sub
I didn't know this was on offer at all. I reckon you'll need to iterate over the items yourself.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog