组合框文字改变了事件 [英] Combo Box Text changed event

查看:59
本文介绍了组合框文字改变了事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个组合框( cmbBatchNo ),我可以在其中加载项目。当我们在项目列表中选择一个项目时, Selectedindexchanged 事件被触发,如果我在组合框中输入新数字,则触发文本更改事件并禁用 expdate ,MRP文本框,但这里没有火。



请帮助我。

Hi,

I have a combo box (cmbBatchNo) in which I can load the list of items. When we select one item in list of items then Selectedindexchanged event is fired and if I enter new number in the combo box then the text changed event is fired and disables the expdate, MRP textboxes but here its not fire.

Please help me.

public void cmbBatchno_SelectedIndexChanged(object sender, EventArgs e)
    {

        if (ViewState["BatchNo"] != null)
        {
            DataTable dtBatchNoDtls = (DataTable)ViewState["BatchNo"];
            for (int i = 0; i < dtBatchNoDtls.Rows.Count; i++)
            {
                if (dtBatchNoDtls.Rows[i]["BatchNo"].ToString() == cmbBatchno.Text)
                {
                    txtExpdate.Text = dtBatchNoDtls.Rows[i]["ExpDate"].ToString();
                    txtMRP.Text = dtBatchNoDtls.Rows[i]["MRP"].ToString();
                    txtRate.Text = dtBatchNoDtls.Rows[i]["Rate"].ToString();
                    if (txtExpdate.Text != "")
                        txtPacks.Focus();
                    else
                        txtExpdate.Focus();
                    break;
                }
                else
                {
                    txtExpdate.Text = string.Empty;
                    txtMRP.Text = "";
                    txtRate.Text = "";
                }
            }
        }
    }

    public void cmbBatchno_TextChanged(object sender, EventArgs e)
    {
        if (ViewState["BatchNo"] != null)
        {
            DataTable dtBatchNoDtls = (DataTable)ViewState["BatchNo"];
            for (int i = 0; i < dtBatchNoDtls.Rows.Count; i++)
            {
                if (cmbBatchno.Text == dtBatchNoDtls.Rows[i]["BatchNo"].ToString())
                {
                    txtExpdate.Enabled = false;
                    txtMRP.Enabled = false;
                    break;
                }
                else
                {
                    txtExpdate.Enabled = true;
                    txtMRP.Enabled = true;
                }
            }
               
        }
    

    }

推荐答案

你在cmbBatchno_TextChanged事件中编写的代码是,如果在cmbBatchno(combobox)中选择的值与检索到的数据中的数字匹配,那么它将禁用文本框。

看到你的code
The code you have written in cmbBatchno_TextChanged event is that if the value selected in cmbBatchno(combobox) matches with the number from retrieved data, then it will disable the textbox.
see your code
if (cmbBatchno.Text == dtBatchNoDtls.Rows[i]["BatchNo"].ToString())
{
    txtExpdate.Enabled = false;
    txtMRP.Enabled = false;
    break;
}                

你写过

txtExpdate.Enabled = false;

这会禁用文本框。如果你想要不禁用文本框,那么在if条件下将其设为true而不是false。喜欢这个

which disables the textbox. if you want that the textbox should not be disabled then make it true instead of false in if condition. like this

txtExpdate.Enabled = true;





需要任何帮助来回复。



Any help needed plz reply.


这篇关于组合框文字改变了事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆