Reputation: 1483
// [in designer] textBoxInContext.AutoCompleteMode = Suggest
// [in designer] textBoxInContext.AutoCompleteSource = CustomSource
AutoCompleteStringCollection autoComplete = new AutoCompleteStringCollection();
autoComplete.AddRange(myArrayofStrings);
textBoxInContext.AutoCompleteCustomSource = autoComplete;
I have this code which works well as documented in MSDN.
Problem: if user types "PS" it shows all the string starting with "PS"; I would like to display all the strings containing "PS"
Any pointers ?
Upvotes: 16
Views: 9241
Reputation: 43
If you don't find another way, I suggest doing it manually:
combobox.TextChanged
or KeyUp
event take its text and compare it to your string array whichever way you want and, after clearing the combobox.Items
, add the found results to the combobox.Items
and make sure to set the DroppedDown
property to true if you have found suggestions.Upvotes: 2
Reputation: 3360
The stupid but fun suggestion: make a class that inherits from AutoCompleteStringCollection and play with it in debug to see if you can fake this out.
The normal suggestion: make your own autocomplete with a listbox.
Upvotes: 0