How to separate the selected item of two combobox with one data source?

In the form, I have two combobox that have the same DataSource (their list of elements is the same). When the user selects an item in one of the controls, another control is also selected. This is not what I want.

I would like both lists to be populated with the same DataSource (as I do now), but I would like their selected elements to be independent of each other.

How can i do this?

+5
source share
2 answers

Or you could use ...

var dataSource = new[] { "item1", "item2", "item3" };
comboBox1.DataSource = dataSource;
comboBox2.BindingContext = new BindingContext();
comboBox2.DataSource = dataSource;
+6
source

. ToArray:

var dataSource = new string[] { "item1", "item2", "item3" };
comboBox1.DataSource = dataSource.ToArray();
comboBox2.DataSource = dataSource.ToArray();
+1

All Articles