ArrayList 需要引用命名空间 using System.Collections;
赋值:
在form_load是添加
ArrayList mylist = new ArrayList();
mylist.Add(new DictionaryEntry("1", "全部"));
mylist.Add(new DictionaryEntry("2", "正常"));
mylist.Add(new DictionaryEntry("3", "终止"));
comboBox1.DataSource = mylist;
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
获取:
获取选中的键值:comboBox1.SelectedValue;
获取选中的键名:comboBox1.Text;
初始化:
comboBox1.SelectedValue = “1”;