Multiple ComboBoxes with same DataSource selectedValue

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

I’ve implemented a Tlp with some ComboBoxes which are bound to the same DataSource. The Goal is to allow to select some kind of Master- and SubItems.

When the selectedValue of one of the ComboBoxes changes, all other are changing too. Is this a Bug or is it normal behavior ?

Have attached an Example.

 

Best Regards

Corvin

Attachment
  • You must to post comments
0
0

Ah, thank you Alex !

Will give it a try.

  • You must to post comments
0
0

Hi,

I had seen the same and I had discussed it with Luca, who found the best solution. Instead of giving each combobox as Datasource a the same IList<Item>,  give a new BindingSource, the Datasource of which is your IList<item>.

i.e.,

var myList = new List<Item> { new Item { ID = 1, Name = “Name1” }, new Item { ID = 2, Name = “Name2” } };

var C1 = new ComboBox();
C1.ValueMember = “ID”;
C1.DisplayMember = “Name”;
C1.DataSource = new BindingSource(myList, null};   // NOT C1.DataSOurce = myList;

var C2 = new ComboBox();
C2.ValueMember = “ID”;
C2.DisplayMember = “Name”;
C2.DataSource = new BindingSource(myList, null};   // NOT C2.DataSOurce = myList;

Best regards,
Alex

 

 

 

  • You must to post comments
Showing 2 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 1, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json