SelectionChangeCommited event on Combobox not triggered

There seems to be a problem with the .Net Combobox control ! Microsoft is stating it isn’t actually a real problem, but still it is something a programmer should know and if needed take care of.

Let me first explain the problem… If you use the mouse to open a combobox, but then use the arrow keys to navigate in the list and change focus with the tab key, the combobox will select the highlighted value, but will NOT trigger the SelectionChangeCommited event !!
So in other words, even though the programmes subscribes to this event to know when a user has selected a value, the program will not notice it.

According to this post : http://weblogs.asp.net/grobinson/archive/2005/09/21/425711.aspx, Microsoft is aware of this and regards it as standard behaviour. So we are left with the only option to write a workaround ourselves.

I’ve found a good starting solution here : https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3409311&SiteID=1, but I think this can be improved ! Because with this given solution, if a user still would use the mouse to select an item we would get the SelectionChangeCommited event twice.
So the workaround is to suppress the base event and only trigger our own. Here is the code…

[tags]SelectionChangeCommitted, combobox, c#[/tags]

Leave a Reply

Your email address will not be published. Required fields are marked *