I have a ComboBox
set up as follows, where KVPList
is an IList
(of KeyValuePair
if it matters):
comboBox.DisplayMember = "Value";
comboBox.ValueMember = "Key";
comboBox.DataSource = KVPList;
I then have set up a binding with SelectedValue
, binding to a BindingSource
(to a DataSet
). For whatever reason, the combo box always turns up blank when the form is displayed. It is properly populated, however (the values of the IList
show up fine and can be selected).
Now, I've tried my best to trace through, and it appears to initially set the SelectedValue correctly when bound, but then somewhere along the way it gets reset to null
. I've played with the order things get called as well, to no avail.
Can anyone shed some light on this or suggest a workaround?
For the record, on the same form, I have another ComboBox
on the same form, with its SelectedValue
bound to the same BindingSource
. The DataSource
is a DataSet
, not an IList
and it works like a charm. It might be an option to make a DataTable
from the IList
, but it seems like a whole lot of extra overhead; I'm generating the IList
from an enumeration.