I have a piece of code where a ComboBox in DropDown mode on a form has as its datasource a fixed ArrayList of unique items; usually this works just fine for users, but very rarely, an error occurs where the SelectedIndex fails to the item corresponding to the item represented by the ComboBox text property entered by the user (even when it is a legitimate item).
To be more specific, a user types a legitimate entry as text in the ComboBox text field and navigates away to another control using the mouse. The text-field continues to show the entry but at some later point, when the user commits the changes using a method that depends on the SelectedIndex corresponding to the text being show, the SelectedIndex is incorrect (on occasion).
The official documentation http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.text.aspx states:
"Setting the Text property to null or an empty string ("") sets the SelectedIndex to -1. Setting the Text property to a value that is in the Items collection sets the SelectedIndex to the index of that item. Setting the Text property to a value that is not in the collection leaves the SelectedIndex unchanged."
So legitimate text entries should move the SelectedIndex to the proper number. I know I can force a consistency check into an event handler before anything important happens, but I was wondering what could be causing this rare bug which flies in the face of the documentation to better understand what ComboBox is actually doing. I'd appreciate any help.