【发布时间】:2014-06-01 18:49:12
【问题描述】:
我的表单加载中有这个,其中包含组合框 (cmbTip)
EventTypeRepository tip = new EventTypeRepository();
cmbTip.DataSource = new BindingSource(tip.FindAll(), null);
cmbTip.DisplayMember = "Value";
cmbTip.ValueMember = "Key";
(FindAll() 是 EventTypeRepository 中的一个方法,它返回 Dictionary(string, EventType>)) 由于某种原因,这会将 MyProject.Model.EventType 显示为所有组合框项目。我什至补充说:
public string toString()
{
return _name + "(" + _id + ")";
}
在我的 EventType 类中,但它仍将名称显示为 MyProject.Model.EventType (有多少事件类型就有多少项,所以我认为它可以很好地显示名称)。我不知道如何解决这个问题...
【问题讨论】:
标签: c# winforms dictionary combobox