Hi,
I was wondering what is the best way to bind a generic collection to a ComboBox.
The thing is that I need a key, value collection like an IDictionary rather than an IList. So binding the IList works fine but I need a ValueMember and a DataMember and I wouldn't know how to do that with an IList
Before generics I used to use an ArrayList, populate it with a HashTable and bind that. However, I don't seem to get that working with generics.
Anyone can help here

ComboxBox - DataBinding Generics
tblazing28
Not the most obvious code - but the following will work:
Dictionary<int, string> lookup = new Dictionary<int, string>();
lookup[0] = "Zero";
lookup[1] = "One";
lookup[2] = "Two";
lookup[3] = "Three";
BindingSource bs = new BindingSource();
bs.DataSource = lookup;
this.comboBox1.DataSource = bs;
this.comboBox1.DisplayMember = "Value";
this.comboBox1.ValueMember = "Key";
Joe Stegman
The Windows Forms Team
Microsoft Corp.
This posting is provided "AS IS" with no warranties, and confers no rights.