工具条组合框onselectionchangecommitted不工作

时间:2016-05-23 23:38:33

标签: c# winforms combobox event-handling toolstrip

当用户在winform上的工具条组合框中选择鼠标时,我试图触发一些代码,并试图使OnSelectionChangeCommitted工作(链接here)类似于{ {3}}问题。我无法使用SelectedIndexChanged方法,因为当用户点击组合框然后触发代码时,会自动选择第一项,而我宁愿不使用焦点或布尔值。

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

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

2 个答案:

答案 0 :(得分:1)

您需要调用基础ComboBox对象才能访问已提交的事件。

bxDEAL_SELECT.ComboBox.SelectionChangeCommitted += ComboBoxOnSelectionChangeCommitted;

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

答案 1 :(得分:0)

您的发件人参数在哪里?

看起来应该是这样的

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