WinForm应用程序下的ComboBox默认只能添加选项值,通过下述方法,可以同时添加key和value
1、定义数据源:
ArrayList list = new ArrayList();
list.Add(new DictionaryEntry("", "请选择软件类型"));
list.Add(new DictionaryEntry("11", "仓储物流类"));
list.Add(new DictionaryEntry("12", "冷链物流类"));
list.Add(new DictionaryEntry("13", "电商物流类"));
2、绑定数据源:
ComSoft.DataSource = list;
ComSoft.DisplayMember = "Value";
ComSoft.ValueMember = "Key";