How can I make a combobox select nothing (ie. SelectedIndex = -1
) after deleting the bound item that was currently selected. I don't like how the next item gets selected after the currently selected item gets deleted. This could lead to some problems with the wrong value 开发者_如何学JAVAbeing selected. Would be ideal if there was a way to add this behaviour directly to an inherited combobox.
I also like the suggestion made by @Cody Gray in the comments. However, I thought about this and another way you might be able to do this is by attaching an Event which fires when you remove an item from the ComboBox. Set the SelectedIndex = -1
in that event handler. Now, I am not sure if there is such a readily available event, so it might be worthwhile to look into it.
In the known bug link posted by Cody Gray, the workaround is to do:
SelectedIndex = 0
SelectedIndex = -1
精彩评论