Return to Snippet

Revision: 34187
at October 19, 2010 02:58 by indra


Initial Code
var choices = new Dictionary<string, string>(); 
choices["A"] = "Arthur"; 
choices["F"] = "Ford"; 
choices["T"] = "Trillian"; 
choices["Z"] = "Zaphod"; 
comboBox1.DataSource = new BindingSource(choices, null); 
comboBox1.DisplayMember = "Value"; 
comboBox1.ValueMember = "Key"; 

//Now you can set comboBox1.SelectedValue = "F" and it will display "Ford"! How cool is that?

Initial URL
http://madprops.org/blog/Bind-a-ComboBox-to-a-generic-Dictionary/

Initial Description

                                

Initial Title
Bind a ComboBox to a generic Dictionary

Initial Tags

                                

Initial Language
C#