结束输入按回车后直接搜索的实现

双击事件KeyPress

通过事件e检测输入字符, 当e.KeyChar == (char)13  时(13是回车,ASCII码13)

 

 private void txtBatchID_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == (char)13)
                {
                    if (txtBatchID.Text != "")
                    {
                        //CommonFunction.ClearGridView(grdItemList, true);
                        //CommonFunction.ClearGridView(grdItemDefect, true);
                        //base.txtBatchID_KeyPress(sender, e);
                        if (ViewBatchInformation(txtBatchID.Text, "RESULT") == false)
                        {
                            return;
                        }
                        string sInspSet = CommonFunction.Trim(dtBatchInfo.Rows[2][1]);
                        int iInspSerVer = CommonFunction.ToInt(dtBatchInfo.Rows[2][3]);
                        if (sInspSet != "" && iInspSerVer != 0)
                        {
                            View_Attach_Insp_Item_List_Detail(txtBatchID.Text, sInspSet, iInspSerVer);
                        }
                        //检验计划
                        DataTable dt2 = QCMLIST.ViewBatchInspectionPlanItemList(txtBatchID.Text);
                        if (dt2 != null)
                        {
                            DevGridControlHelper.BindData(gdcInspItemAll, dt2, new int[] { 1, -1, 1, -1, 1, 1 });
                            gdvInspItemAll.Columns["FLOW"].Group();
                            gdvInspItemAll.Columns["OPER"].Group();
                            gdvInspItemAll.ExpandAllGroups();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonFunction.ShowMsgBox(ex.Message);
            }
        }

==============

try
            {
                string sCoaId = gluCOATemplate.Text;
                string sBacthId = txtLotID.Text;
                if (e.KeyChar == (char)13)
                {
                    if (txtLotID.Text != "" && sCoaId != "")
                    {
                        DataTable dt = new DataTable();
                        dt = QCMLIST.QCM_View_COA_Detail(sCoaId, sBacthId);
                        if (dt != null)
                        {
                            DevGridControlHelper.BindData(gdcCOAItem, dt);
                            DevGridControlHelper.BindData(gdcCOAItem, dt, new int[] { 1, 1, 1, 1, 1, 1 });
                        }

                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                CommonFunction.ShowMsgBox(ex.Message);
                return;
            }

 

转载于:https://my.oschina.net/8824/blog/3084045

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值