
This example show you how to use dictionary as data source for combobox.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Dictionary <string , string> dic1 = new Dictionary<string, string>(); dic1.Add("Zero", "0"); dic1.Add("One", "1"); dic1.Add("Two", "2"); dic1.Add("Three", "3"); dic1.Add("Four", "4"); dic1.Add("Five", "5"); System.Windows.Forms.ComboBox combo1 = new System.Windows.Forms.ComboBox(); combo1.DataSource = new BindingSource(dic1, null); combo1.DisplayMember = "Key"; combo1.ValueMember = "Value"; |