Reputation: 41
I am using a simple ComboBox in C#. I put in 3 items: "apple", "banana", and "orange". Here is what I do:
Is this the expected behaviour? If I hightlight "orange" and tab out, I would expect either:
I overcome this by using the comboBox.Leave
event handler to manually set the text field to be the selectedItem
however, I would like to know if I am missing some fundamental concepts here.
It seems logical that if selection changes, the comboBox.Text
should reflect this without any manual intervention?
Upvotes: 4
Views: 2741
Reputation: 15813
I believe you have it figured out correctly. In a combobox, the selecteditem does not have to be the same as the text. This allows non-items to be entered in the text of the combobox. You can just ignore the SelectedItem and use the text field.
Upvotes: 1