c# - I need to add the selected item of a combo box to the end of selected item in the list box -
this data in list box, database
johnie black sarah smith carol willis maggie dubois
this data in combo box
(m) (f)
i want select name in listbox when proceed select gender combobox value select must added end of name selected
example.
carol willis(f)
this have tried:
private void form1_load(object sender, eventargs e) { this.namestableadapter.fill(this.namesdataset.names); combobox1.items.add("(m)"); combobox1.items.add("(f)"); combobox1.selectedindex = 0; listbox1.selectedindex = 0; } //the code above loads items combobox //for lisbox connected database using option "use data bound items"
any form of appreciated
this should point right direction:
public listbox lbnames = new listbox(); public combobox cbxgender = new combobox(); // combobox selected index changed event private void cbxgender_selectedindex_changed(object sender, eventargs e) { // check if there selected items if(lbnames.selecteditems.count == 1 && cbxgender.selecteditem != null) { // replace previous added gender regex.replace(lbnames.selecteditem.tostring(), @".+(\([mf]\))", ""); // append new gender lbnames.items[lbnames.selectedindex] = lbnames.selecteditem.tostring() + cbxgender.selecteditem.tostring(); } }
wasnt tested, hint.
Comments
Post a Comment