I am getting an exception on this line of code
object current = comboBoxFunction.SelectedValue;
The runtime exception is
Index 0 does not have a value.
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at System.Windows.Forms.ListControl.get_SelectedValue()
The problem is that this is hard to duplicate, I've stepped through the code where SelectedValue is null and that doesn't cause any problems. The ComboBox is being databound.
During initialization I do this
comboBoxFunction.Items.Clear();
comboBoxFunction.DataSource = functions;
comboBoxFunction.ValueMember = "Value";
comboBoxFunction.DisplayMember = "DisplayName";
comboBoxFunction.SelectedIndex = 0;
After initialization that is when the line that gets the exception is executed
object current = comboBoxFunction.SelectedValue;
Any ideas as to what this error means and how I can duplicate it? Thanks