We spent almost 3 hours today on trying to figure a weird problem about databinding combo box. The error just doesn’t make sense at all. What we wanted to do is very general and simple, showing text in display area, but save key value back to object’s property.
We kept getting the selected index back to -1 when tabbing out from combo box control, debugged into combobox_selectIndexChanged method, tried to do a cast to int from comboBox.SelectedValue. The comipler didn’t allow us to do that, complained data should be less than infinity.
What? We then added a intermediate cast, first cast to int, then cast this int to short. The problem went away.
That why, short and int just don’t match automatically when databinding.
Another example of telling me that UI work is hard.