我有一个combobox
,我希望在其中显示一个字符串DisplayMember
,Dictionary<string,string>
为ValueMember
。我有一个列表,其中包含带有字符串和字典的对象,这个列表我用作DataSource
的{{1}}。
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";
按预期工作,“文字”显示在DisplayMember
中,但当我收到ComboBox
时,我只收到一串“ValueMember
”,而不是我想要的字典。我正在努力,还是有更好的选择?
答案 0 :(得分:0)
vector < string > splitstring;
boost::split(splitstring, *pos, boost::is_any_of(" "));