SelectionChangeCommitted is not getting fired where it should does

G

Guest

SelectionchangeCommitted event is very useful in capturing index change
events by user. It works well except one place.
Open combo dropdown by mouse or keyboard, press up or down arrow, we can
easily see selection is changed in combo box. After that although user
presses escape, changed selection does not go back to the selection before
dropdown is open. So it is sure that selection is changed by user action. If
I try to get SelectedIndex from combo, the index has changed. In this case,
SelectedIndexChanged event gets fire everytime I press up or dpwn arrow, but
SelectionChangeCommitted doesn't fire at all. I am not sure it is a bug or a
feature. Anyway it gets comfuse to the programmer.
To get consistant behavior on SelectionChangeCommitted event, I have to
extend ComboBox class as follows.

public class ComboBoxExt : ComboBox
{
protected override void OnSelectedIndexChanged(EventArgs e)
{
if(base.DroppedDown)
base.OnSelectionChangeCommitted(e);
base.OnSelectedIndexChanged(e);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top