Tuesday, February 14, 2012

Bind generic dictionary collection to combobox


Dictionary<string, string>  DicSearch;
DicSearch = new Dictionary<string, string>();
DicSearch.Add("1", "Mohit");
DicSearch.Add("2", "Agrawal");

cboSearch.DataSource  = new BindingSource(DicSearch, null);
cboSearch.DisplayMember = "value";
cboSearch.ValueMember = "key";
DicSearch = null;

No comments:

Post a Comment

Hash Table in C#

 The Hashtable is a non-generic collection and used to store the key/value pairs based on the hash code of the key. Key will be used to acce...