Add Dictionary/Hash Table Object to Combo Box

Dictionary parameters = new Dictionary();
parameters.Add(10, "Venu");
parameters.Add(20, "Pavuluri");

Hashtable obj = new Hashtable();
obj.Add("11", "Leon");
obj.Add("12", "Sun");

comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
comboBox1.DataSource = new BindingSource(parameters, null);
//comboBox1.DataSource = new BindingSource(obj, null);

Difference Between Dictionary & Hash Table Objects:

A Dictionary is closely related to a HashTable. Important difference is that a Dictionary is generally faster than a Hashtable for storing data. The reason is that a Dictionary takes strongly-typed values as its input like Dictionary parameters = new Dictionary() but Hashtable not like that.

Comments

Popular posts from this blog

Windows Azure Package Build Error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Resource ID : 1. The request limit for the database is 180 and has been reached.

How to get Client's Location using IPAddress