winforms - make autocomplete textbox using tableadapter windows forms C# -
i have piece of code autocomplete search textbox
autocompletestringcollection coll = new autocompletestringcollection(); datatablereader reader=this.customertableadapter.getdata().createdatareader(); while(reader.read()){ coll.add(reader.getstring(0)); } search.autocompletecustomsource = coll;
is best way perform it? or there function make autocomplete source column directly?
moreover code filters first name, when use piece of code gridview gives me better search abilities catches part of name
private void search_keyup(object sender, keyeventargs e) { string outputinfo = ""; string[] keywords = search.text.split(' '); foreach (string word in keywords) { if (outputinfo.length == 0) { outputinfo = "(name '%" + word + "%')"; } else { outputinfo += " , (name '%" + word + "%')"; } } //applies filter dataview myview.rowfilter = outputinfo; }
suggestions please
this piece of code trick without using loops, fills 1 column of table in string array , used autocompletesource
datatable dt = this.data_alldataset.merchandise; //use linq method syntax pull title field dt string array... string[] postsource = dt .asenumerable() .select<system.data.datarow, string>(x => x.field<string>("name")) .toarray(); var source = new autocompletestringcollection(); source.addrange(postsource); cat_name.autocompletecustomsource = source; cat_name.autocompletemode = autocompletemode.suggest; cat_name.autocompletesource = autocompletesource.customsource;