Friday, February 09, 2007

.Net form ComboBox SelectedIndex = -1 seems does not work.

I ran into a problem in programming ComboBox on .Net Windows Form, we were clearing the ComboBox and then set the ComboBox.SelectedIndex = -1, which supposed to deselect the SelectedItem. However, the ComboBox still showing the old SelectedItem.

I found a workaround, first set the ComboBox.SelectedIndex = -1 before you call ComboBox.Items.Clear()

No comments: