Search code examples
c#winformscomboboxevent-handlingtoolstrip

Toolstrip combobox onselectionchangecommitted not working


I'm trying to trigger some code when a user makes a mouse selection in a toolstrip combobox on a winform and have been trying to get the OnSelectionChangeCommitted to work (link here) similar to this question. I can't use the SelectedIndexChanged method because the first item is selected automatically when a user clicks on the combobox which then triggers the code, and I'd prefer not to use focus or a boolean.

The code below doesn't trigger when the user makes a selection in the combobox, what am I doing wrong?

protected virtual void bxDEAL_SELECT_OnSelectionChangeCommitted(EventArgs e)
        {
            MessageBox.Show("onselect value changed");
        }

Solution

  • Where is your sender parameter?

    It should look something like this

    private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
    {
         // your code
    }