工具条组合框 onselectionchangecommitted 不起作用

Toolstrip combobox onselectionchangecommitted not working

我试图在用户在 winform 的工具条组合框中进行鼠标选择时触发一些代码,并且一直在尝试让 OnSelectionChangeCommitted 工作(link here) similar to this 问题。我不能使用 SelectedIndexChanged 方法,因为当用户单击组合框然后触发代码时会自动选择第一项,我不想使用焦点或布尔值。

当用户在组合框中进行选择时,下面的代码不会触发,我做错了什么?

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

你的sender参数在哪里?

它应该看起来像这样

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

您需要调用底层 ComboBox 对象来访问已提交的事件。

bxDEAL_SELECT.ComboBox.SelectionChangeCommitted += ComboBoxOnSelectionChangeCommitted;

private void bxDEAL_SELECT_OnSelectionChangeCommitted(object o, EventArgs eventArgs)
{
    \Your code goes here.
}