I already have seen that there are many Topics about this,but I am not able to make them work.
I have an Combobox which shall be filled with an List of String.
this.elementBox.DataSource = this.elementList;
this.elementBox.SelectedIndexChanged += new EventHandler(this.elementBox_SelectedIndexChanged);
If I put this into the Code my GUI does not appear, I suppose the assignment of the data is wrong. I already tried Bindingsource.
Then I want to fill an Combobox with an List of Objects and this does not work either. itemData is an Dictionary with an String as key and the Objectlist as value.
box1.DataSource = itemData["ele1"];
box1.DisplayMember = "Name";
box2.DataSource = itemData["ele2"];
box2.DisplayMember = "Id";
I tried to play around with DisplayMember and Value but I am not able to get it to work. The Type of the List is MyItem:
class myItem{ int Id; Internal data;}
class Internal {String name;}
Obviously I want to show the myItem.data.name in the Combobox, but I do not know how to get it. Furthermore what is the difference of DisplayMember and Value?