winforms - How to prevent combobox changing together? -
i have windows form 2 combo boxes on , fill list.
when change fist combo box value why second combo box value changing first one?
how can prevent it?
i set no event or can cause problem.
list<myclass> mc = new list<myclass>(); mc.add(new myclass() { id = 10, name = "no 10" }); mc.add(new myclass() { id = 27, name = "no 27" }); combobox1.datasource = mc; combobox1.valuemember = "id"; combobox1.displaymember = "name"; combobox2.datasource = mc; combobox2.valuemember = "id"; combobox2.displaymember = "name"; my class :
class myclass { public int id { get; set; } public string name { get; set; } }
it works because comboboxes have same datasource. try copying or cloning list comboboxes have independent datasources.
Comments
Post a Comment