当项目列表为空时,SelectIndexChanged Combobox事件不会触发

时间:2017-04-05 11:47:00

标签: c# winforms events combobox

在我的代码中我有了combobox,我通过bindingData控件绑定它。我使用selectIndexChanged为组合框中的每个活动项做一些代码..

我的问题是在这种情况下: 我的bindingData为空(所以组合框索引= -1)然后我将项目“item1”添加到我的bindingData(活动组合框项目是“item1”),但SelectIndexChanged没有触发。为什么?

代码:

   //first combobox is empty
        myBindingSource.DataSource = null;
        comboBox_Choixpiece.DataSource = myBindingSource;

   //then combobox Contains 1 item but SelectIndexChanged event is not firing !!
        myBindingSource.DataSource = someSource;
        comboBox_Choixpiece.DataSource = myBindingSource;

请帮帮我

0 个答案:

没有答案