阅读没有文本框条形码读取的条形码 [英] Reading barcode with barcode reading without textbox

查看:162
本文介绍了阅读没有文本框条形码读取的条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i需要在我的C#应用​​程序中创建POS窗口..现在我创建了所有东西,只有一件事我想做:

i想要在没有文本框的情况下搜索条形码..所以如果gridview或任何其他控件都集中在条形码阅读器上,我可以获得条形码。



那么当条形码阅读器开始阅读代码时会发生什么事?



我尝试过的事情:



i尝试搜索但是我找不到任何明确答案



i need to create POS window in my C# application ..now i created all thing , only one thing i want to do :
i want to search for barcode without having textbox .. so i can get the barcode after barcode reader read it if gridview or any other control was focused ..

so what is the event which fired when barcode reader begin reading the code ?

What I have tried:

i tried to search about that but i can't find any Clear answers

推荐答案

处理表单上的全局键盘输入这:

Handle the global keyboard input on your form like this :
private string _barcode = "";
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
     char c = (char)keyData;

     if (char.IsNumber(c))
         _barcode += c;

     if (c == (char)Keys.Return)
     {
         DoSomethingWithBarcode(_barcode);
         _barcode="";
     }

     return base.ProcessCmdKey(ref msg, keyData);
}

并使用 DoSomethingWithBarcode()方法中的条形码值执行所需操作。

and do what you need with the barcode value in DoSomethingWithBarcode() method.


问题在于,大多数条形码扫描仪都配置为充当键盘,这给出了两个问题:

1)你无法区分真正的键盘数据和真正的条形码键盘因为数据源不是由系统保存的。

2)因为它是键盘数据,它会自动路由到当前活动的输入控件,而不是非输入控件。 />


您通常可以将扫描仪设置为提供引入和尾随代码,以便您将键盘与条形码数据区分开来 - 尽管如何执行此操作因扫描仪而异扫描仪甚至模型到模型,所以你需要检查制造商如何做到这一点 - 这解决了问题一。

它也可以帮助解决问题二:通过捕获键盘输入在表单级别(覆盖e ProcessCmdKey 在您的表单中执行此操作)并查找您可以识别和处理条形码的导入和尾出序列。

但是......在你这样做之前要仔细考虑:你经常去超市,操作员必须手动输入条形码数据,因为物品不会扫描,条形码丢失,条形码损坏了吗?使用文本框可让操作员将数据作为备份系统输入,通常非常必要......
The problem is that most barcode scanners ship configured to act as a keyboard, which gives two problems:
1) You can't tell the difference between "real" keyboard data and "genuine barcode" keyboard data because the source of the data is not preserved by the system.
2) Because it's keyboard data, it is automatically routed to the currently active input control, and not to non-input controls.

You can normally set the scanner to provide "lead in" and "tail out" codes which let you differentiate keyboard from barcode data - though how you do that varies from scanner to scanner and even model to model, so you will need to check with the manufactureras to how you do that - which solves problem one.
It may also help solve problem two as well: by capturing the keyboard input at the form level (override ProcessCmdKey in your form to do this) and looking for your lead in and tail out sequences you can identify and process your barcode.
But ... think carefully before you do this: how often do you go to the supermarket and an operator has to manually enter barcode data because the item won't scan, the barcode is missing, the barcode is damaged? Using a textbox lets the operator enter the data as a backup system and is normally pretty necessary ...


这篇关于阅读没有文本框条形码读取的条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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