c# - two combobox firing an event for same function -


there 2 comboboxes. 1 created drag&drop , set event selectedindexchanged. , 2nd combobox created manually, not given event. when change 2nd combo, it's firing event 1st combo's function.

form prompt = new form(); prompt.width = 300; prompt.height = 150;      combobox cmbox = new combobox() { left = 70, top = 24, width = 100, height=150 };     cmbox.dropdownstyle = system.windows.forms.comboboxstyle.dropdownlist;     cmbox.valuemember = "value";     cmbox.displaymember = "text";  prompt.showdialog(); 

i tried, not working:

cmbox.selectedindexchanged -= new system.eventhandler(combobox1_selectedindexchanged); 

p.s: using same bindsource.

if they're sharing bindingsource, changing value in 1 control change value in other control well.

when change value in second combobox, value in first combobox changes too, fires selectedindexchanged event.

create separate bindingsource each control, or if it's collection, try assigning collection directly each combobox.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -