开发者

Delete currently selected bound combobox item and then have it select nothing?

开发者 https://www.devze.com 2023-02-06 00:32 出处:网络
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 selectedafter the currently selected it

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号