Posts

Showing posts from May, 2008

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.