2 comboboxes with the same datasource act as 1. Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 instances of a user control on a windows form. Each user control has a combobox. I have set the datasource for each combobox to the same collection of objects. I would expect these two comboboxes to act completely independently, but with the same selections available. What I am seeing, however, is that if I change the selected value of one combobox, that the selected value of the other combo box changes as well. Does anybody out there know what is going on? Is this just a bug in the framework, or is it designed to do this intentionally when using the same datasource? Thanks.
 
Hello =?Utf-8?B?SGFycnkgS2Vjaw==?=,
I have 2 instances of a user control on a windows form. Each user
control has a combobox. I have set the datasource for each combobox
to the same collection of objects. I would expect these two
comboboxes to act completely independently, but with the same
selections available. What I am seeing, however, is that if I change
the selected value of one combobox, that the selected value of the
other combo box changes as well. Does anybody out there know what is
going on? Is this just a bug in the framework, or is it designed to
do this intentionally when using the same datasource? Thanks.

You'll need to assign new BindingContext objects to the comboboxes:

comboBox1.BindingContext = new BindingContext();

If they have the same binding contexts, the will share the same position in the datasource.
 
Back
Top