【问题标题】:Combo box's Selected index changed event not getting fired when any item is selected选择任何项目时不会触发组合框的 Selected index changed 事件
【发布时间】:2012-10-03 09:09:35
【问题描述】:

我有一个表格,其中有两个组合框和一个网格, 我已经在组合框的 selectedindex 更改事件上编写了过滤代码,为组合框设置了 SuggestAppend 属性。当我输入一个国家名称(例如印度)并按 Enter 时,选定的索引更改事件不会立即触发,当我点击某个地方时它会触发并给出输出。 请建议我该怎么做。在此先感谢

protected void cbCountry_SelectedIndexChanged(object sender, EventArgs e) { 获取条件(); 填充网格(); }

 public string GetCondition()
        {
            string Condition = "";
            if (cbEmployee.SelectedIndex > 0)
            {
                Condition = Condition + " And reg_no=" + cbEmployee.SelectedValue;
            }

            if (cbCountry.SelectedIndex > 0)
            {
                Condition = Condition + " And country='" + cbCountry.SelectedItem.Text + "'";
            }
  return Condition;
        }

【问题讨论】:

    标签: combobox


    【解决方案1】:

    检查声明事件的表单设计器 (designer.cs)

    this.cbCountry.SelectedIndexChanged += new System.EventHandler(this.cbCountry_SelectedIndexChanged);

    如果没有声明,你可以在设计器或表单加载中添加它

    【讨论】:

    • 你的意思是这样吗??
    • 哦,对不起,我以为是 windows 窗体。
    猜你喜欢
    • 2018-03-05
    • 2015-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    相关资源
    最近更新 更多