|
-
Oct 3rd, 2007, 10:37 PM
#1
Thread Starter
Member
[RESOLVED] [2005] Best Matched ListView
I am trying to figure out how to select the best matched item. this is what i got so fare, but it only find the exect one:
vb Code:
Dim Itms As ListViewItem = ListView1.FindItemWithText(TextBox1.Text, True, 0, False)
If Not (Itm Is Nothing) Then
ListView1.Items(Itms.Index).Selected = True
ListView1.EnsureVisible(Itms.Index)
ListView1.Focus()
Else
MessageBox.Show("No Items Where Found In The List")
End If
-
Oct 3rd, 2007, 10:59 PM
#2
Re: [2005] Best Matched ListView
Have you read the documentation for the ListView.FindItemWithText method? It only finds an exact match because you are SPECIFICALLY telling to only find an exact match:
The text parameter can specify a substring of the desired matching text. This method will return the first item that starts with the specified text, unless false is passed in for isPrefixSearch. For example, if a ListView contains two list items—the first item's text set to "angle bracket" and the second item's text set to "bracket"—a call to FindItemWithText passing "brack" as the search text will return the item whose text is "bracket". If isPrefixSearch is set to false, this call will return a null reference (Nothing in Visual Basic).
You should be specifying True for the last parameter or, given that that's the default behaviour, just don't specify a fourth parameter at all. Please read the documentation first in future.
-
Oct 3rd, 2007, 11:09 PM
#3
Thread Starter
Member
Re: [2005] Best Matched ListView
but when i get rid of it my loop continues for ever
-
Oct 3rd, 2007, 11:14 PM
#4
Thread Starter
Member
Re: [2005] Best Matched ListView
o i found my problem. its the code following it , thanks
-
Oct 3rd, 2007, 11:29 PM
#5
Re: [RESOLVED] [2005] Best Matched ListView
Well, if that was the problem then that should have been the problem you posted. You can't just change parameter values arbitrarily when they are intended for a specific purpose.
Are you saying that FindItemWithText doesn't return if you specify True as the fourth parameter? I'll wager not, because I just tested it and it worked as expected for me. My guess is that you have some sort of loop that is never exiting as a result of the way you've structured your code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|