How to get value of SelectedValue in ComboBox filled with Dictionary
Looks like you have to cast SelectedValue
into KeyValuePair<int, int>
:
string value = ((KeyValuePair<int, int>)comboBox1.SelectedValue).Value.ToString();
However, you should put a brakepoint there and check what type SelectedValue
really is.
I assume it's KeyValuePair<int, int>
because your source collection is Dictionary<int, int>
and because of output string for SelectedValue.ToString()
which is [1, 202]
.