Goal
I'd like to have my ComboBox items suggest and append its items when something is contained in them, not just via the StartsWith function.
My ComboBox is bound to a DataView which contains clients [CompanyName], [Address], [City] in a long concatenation.
I want my users to be able to type in the city and still find the records which matches with all of the fields above. I know this is possible with Infragistics but I don't have that package.
Search Term: "Sher"
- Costco, 123 1st Avenue, Sherbrooke
- Provigo, 344 Ball Street, Sherbrooke
- Sherbox, 93 7th Street, Montreal
Is this possible in VB.Net or should I be searching for something else?
A
ComboBox
,TextBox
and I think aDropDownList
has AutoComplete properties Look at http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.autocompletemode(v=vs.110).aspxIt explains which AutoCompleteMode you should use and how to set the AutoCompleteSource
I did some research and found the following question:
Override Winforms ComboBox Autocomplete Suggest Rule
In that question they reffer to another question:
C# AutoComplete
Improved the technique demonstrated by BenD in his answer so as to have the mechanism handle a bit more elegantly certain cornercases:
Sorry for another answer in C# but I have a more improved answer based on xDisruptor's code.
Using kinda behavior (decorator).
You don't have to subclass ComboBox and change all existing combos in the designed.
Be careful when using Datasource instead of Items collection, because it'll raise an exception.
Code:
Usege:
TIP: Can be further improved by making an extension to the ComboBox class like myCombo.ToAutoComplete()
You could try the following lines, it worked for me