I'm currently in the process of making a desktop application in C# but I'm having some problems getting a combo box working as I expected.
Basically, I've got a combo box filled with values. When the user presses a button it should do something with the value in the combo box and then automatically move to the next item. (I'm using SelectedIndex to do that).
Now, on the first click of the button, everything works OK and the combo box moves down one place (at least, it does visually)... but when it's clicked again, the program crashes (ArgumentOutOfRangeException). It's setting the IndexSelected value to -1, which according to the documentation means no item is selected. When I manually select the combo box again and click the item that (visually) is already selected... everything works fine.
So my question is, is this how combo boxes are supposed to work (not good for automated stuff) or am I doing something stupid? I've tried putting a bit in the code to give the combo box focus again (comboBox1.Focus()) but it doesn't seem to make any difference.
Sorry for waffling on a bit! Hope it made sense.
Thanks in advance.
Basically, I've got a combo box filled with values. When the user presses a button it should do something with the value in the combo box and then automatically move to the next item. (I'm using SelectedIndex to do that).
Now, on the first click of the button, everything works OK and the combo box moves down one place (at least, it does visually)... but when it's clicked again, the program crashes (ArgumentOutOfRangeException). It's setting the IndexSelected value to -1, which according to the documentation means no item is selected. When I manually select the combo box again and click the item that (visually) is already selected... everything works fine.
So my question is, is this how combo boxes are supposed to work (not good for automated stuff) or am I doing something stupid? I've tried putting a bit in the code to give the combo box focus again (comboBox1.Focus()) but it doesn't seem to make any difference.
Sorry for waffling on a bit! Hope it made sense.
Thanks in advance.