Possible Duplicate:
C# AutoComplete
I’ve a standard winform combobox. I’ve set its AutoComplete property to true. I want to change the comparison between typed text and items text which is done automatically by the UI.
Something like:
autoCompleteCombo.XXXX = new Func<string, string, bool> { (search, item) => item.Contains(search) };
Note: the function wrote is just an example. What I really want a little more complex.
Since you’ve updated your question, I understand your question better. You’ve also said the underlying data and function aren’t pertinent, which makes it difficult to understand exactly what you’re trying to achieve, so my recommendation would be to create a custom
ComboBoxand see if you can handle the matching on your own.I think the most elegant way to write a function to test whether the typed text is an item in a
ComboBoxwould be to use an extension method. Your calls would look like this:The extension methods could be created as follows where you can customize exactly how your search logic is to work. In the two extension methods I wrote below, they simply check to see if the text typed into the
ComboBoxis found in theAutoCompleteCustomSourcecollection, or, in the second function, if the text is found in theItemscollection.