You use the DisplayMember and ValueMember to determine what the ComboBox will display, and what will be returned from SelectedValue. When you set the DataSource property, the ComboBox will use the property described by DisplayMember to render a string to the user.
- DataSource
- DisplayMember
- ValueMember
Something like this
public class Item {
string Name { get; set; }
string Value { get; set; }
}
ComboBox box = new ComboBox();
box.DisplayMember = "Name";
box.ValueMember = "Value";
box.DataSource = new [] { new Item() { "Test", "test" } };
If you don't set ValueMember the actual Item is returned instead, and if you don't set DisplayMember, the items ToString() method will be used to get the string presented to the user.
I'm not sure if this will work or if it may change what you have, but you could try it at least :)
The thing is, I'm not certain what BindingSource does when it gets a dictionary as its datasource. I suppose it treats it as an IEnumerable<KeyValuePair<>> though, so your code should work, but well, it doesn't, so perhaps this will..
BindingSource source = new BindingSource();
source.DataSource = typeof(KeyValuePair<string, string>);
foreach (KeyValuePair<string, string> pair in filterItems) {
source.Add(pair);
}
options_filterby = source;