vb.net - How to SuggestAppend a ComboBox containing a string -



vb.net - How to SuggestAppend a ComboBox containing a string -

goal

i'd have combobox items suggest , append items when contained in them, not via startswith function.

my combobox bound dataview contains clients [companyname], [address], [city] in long concatenation.

i want users able type in city , still find records matches of fields above. know possible infragistics don't have package.

search term: "sher"

costco, 123 1st avenue, sherbrooke provigo, 344 ball street, sherbrooke sherbox, 93 7th street, montreal

is possible in vb.net or should searching else?

i did research , found next question:

override winforms combobox autocomplete suggest rule

in question reffer question:

c# autocomplete

let's quote best reply question

the existing autocomplete functionality supports searching prefix. there doesn't seem decent way override behavior.

some people have implemented own autocomplete functions overriding ontextchanged event. that's best bet.

for example, can add together listbox below textbox , set default visibility false. can utilize ontextchanged event of textbox , selectedindexchanged event of listbox display , select items.

this seems work pretty rudimentary example:

public form1() { initializecomponent(); acsc = new autocompletestringcollection(); textbox1.autocompletecustomsource = acsc; textbox1.autocompletemode = autocompletemode.none; textbox1.autocompletesource = autocompletesource.customsource; } private void button1_click(object sender, eventargs e) { acsc.add("[001] kind of item"); acsc.add("[002] other item"); acsc.add("[003] orange"); acsc.add("[004] pickles"); } void textbox1_textchanged(object sender, system.eventargs e) { listbox1.items.clear(); if (textbox1.text.length == 0) { hideresults(); return; } foreach (string s in textbox1.autocompletecustomsource) { if (s.contains(textbox1.text)) { console.writeline("found text in: " + s); listbox1.items.add(s); listbox1.visible = true; } } } void listbox1_selectedindexchanged(object sender, system.eventargs e) { textbox1.text = listbox1.items[listbox1.selectedindex].tostring(); hideresults(); } void listbox1_lostfocus(object sender, system.eventargs e) { hideresults(); } void hideresults() { listbox1.visible = false; }

there's lot more without much effort: append text text box, capture additional keyboard commands, , forth.

vb.net winforms combobox autocomplete contains

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -