Dictionary to fill a ComboBox

Simplest was to have key / value pairs displayed in a ComboBox.

comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
Dictionary names = new Dictionary();
names.Add("1", "one");
names.Add("2", "two");
comboBox1.DataSource = names.ToArray();

//and then in the:
comboBox1_SelectedValueChanged
//you can listen to the
comboBox1.SelectedValue / comboBox1.Text

Warning: count(): Parameter must be an array or an object that implements Countable in /home/cselian/public_html/blog/wp-includes/class-wp-comment-query.php on line 405

Leave a Comment