I have a combobox, where I would like to display a string as the DisplayMember and have a Dictionary as the ValueMember. I have a list containing the objects with the string and dictionary, this List I use as DataSource for the ComboBox.
List<myObject> myList = new List<myObject>{
new myObject {myDisplayMember = "TEXT", myValueMember = new Dictionary<string,string> {{"A","ABC"},{"D","DEF"}}}
};
myComboBox.DataSource = new BindingSource(myList, null);
myComboBox.DisplayMember = "myDisplayMember";
myComboBox.ValueMember = "myValueMember";
The DisplayMember works as expected and "TEXT" is shown in the ComboBox, but when I get the ValueMember I only get a string of "myValueMember", instead of the dictionary I'd like to get. Is what I'm trying possible, or are there any better alternatives?
Aucun commentaire:
Enregistrer un commentaire