winform之combobox
绑定键值对:
ArrayList mylist = new ArrayList(); mylist.Add(new DictionaryEntry("WinFormURL", "http://www.cnblogs.com/cate/winform/")); mylist.Add(new DictionaryEntry("ASPNETURL", "http://www.cnblogs.com/cate/aspnet/")); mylist.Add(new DictionaryEntry("JihuaURL", "http://www.cnblogs.com/jihua/")); comboBox1.DataSource = mylist; comboBox1.DisplayMember = "Value"; comboBox1.ValueMember = "Key";
使用comboBox1.SelectedText获取所选项的值,
使用comboBox1.SelectedValue获取所选项的键
所获取键值 都是对象(object),根据需要可转换成其它类型,例如如string
ArrayList 需要引用命名空间 using System.Collections;
起风了,努力生存