Problem:
The following code snippet demonstrates how to bind dictionary to combobox in winforms using c#.
Dictionaryitems = new Dictionary (); items.Add("KEY1", "Value 1"); items.Add("KEY2", "Value 2"); ..... ..... comboBox1.DataSource = new BindingSource(items,null); comboBox1.DisplayMember = "VALUE"; comboBox1.ValueMember = "KEY";
Or simply
comboBox1.DataSource = items.ToArray() comboBox1.DisplayMember = "VALUE"; comboBox1.ValueMember = "KEY";
Usage:
Now data is bound to combobox, we can access it by SelectedValue property.
ComboBox1.SelectedValue.ToString()