以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于扫描枪触发ValueChanged问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=112770)

--  作者:benwong2013
--  发布时间:2018/1/2 17:28:00
--  关于扫描枪触发ValueChanged问题
在文本框的代码为:
Dim no As String = e.Form.Controls("样品编号").Value
Dim dr As DataRow = DataTables("T_Report").SQLFind("报告编号 = \'" & no & "\'")
If dr IsNot Nothing Then
    e.Form.Controls("样品名称").value = dr("样品名称")
    e.Form.Controls("客服人员").Value = dr("客服人员")
    e.Form.Controls("储存条件").Value = dr("储存条件")
    e.Form.Controls("是否抽检").checked = dr("是否抽检")
Else
    e.Form.Controls("样品名称").value = Nothing
    e.Form.Controls("客服人员").Value = Nothing
    e.Form.Controls("储存条件").Value = Nothing
    e.Form.Controls("是否抽检").checked = False
End If

扫描枪设置在扫描之后会加回车,但在以下用扫描枪扫描样品编号输入之后不会触发离开控件,请问怎么处理?

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20180102172758.png
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2018/1/2 18:15:00
--  

为什么不直接用keydown事件?

 

If e.keycode = 13 Then

    e.cancel = true
    Dim no As String = e.Form.Controls("样品编号").text
    Dim dr As DataRow = DataTables("T_Report").SQLFind("报告编号 = \'" & no & "\'")
    If dr IsNot Nothing Then
        e.Form.Controls("样品名称").value = dr("样品名称")
        e.Form.Controls("客服人员").Value = dr("客服人员")
        e.Form.Controls("储存条件").Value = dr("储存条件")
        e.Form.Controls("是否抽检").checked = dr("是否抽检")
    Else
        e.Form.Controls("样品名称").value = Nothing
        e.Form.Controls("客服人员").Value = Nothing
        e.Form.Controls("储存条件").Value = Nothing
        e.Form.Controls("是否抽检").checked = False
    End If
End If