【发布时间】:2010-10-26 10:15:22
【问题描述】:
考虑有一个通过其 DataSource 属性填充的 ComboBox。 ComboBox 中的每一项都是一个自定义对象,ComboBox 设置有DisplayMember 和ValueMember。
IList<CustomItem> aItems = new List<CustomItem>();
//CustomItem has Id and Value and is filled through its constructor
aItems.Add(1, "foo");
aItems.Add(2, "bar");
myComboBox.DataSource = aItems;
现在的问题是,我想将项目读取为将在 UI 中呈现的字符串。考虑到我不知道 ComboBox 中每个项目的类型(CustomItem 我不知道)
这可能吗?
【问题讨论】:
标签: c# winforms .net-2.0 controls combobox