I have a combobox that is bound to a dictionary like this:
Dictionary<int, string> comboboxValues = new Dictionary<int, string>();
comboboxValues.Add(30000, "30 seconds");
comboboxValues.Add(45000, "45 seconds");
comboboxValues.Add(60000, "1 minute");
comboBox1.DataSource = new BindingSource(comboboxValues , null);
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
I'm getting the key from the SelectedItem like this:
int selection = ((KeyValuePair<int, string>)comboBox1.SelectedItem).Key;
So if my user chooses the "45 seconds" option, I get back 45000 and save that value to an XML file. When my application is loaded, I need to read that value and then automatically set the combobox to match. Is it possible to do this when I only the key of 45000? Or do I need to save the value ("45 seconds") to the file instead of the key?