如何在C#应用程序中使用Code Barre扫描程序? [英] How I Can Use Code Barre Scanner In C# Application ?

查看:108
本文介绍了如何在C#应用程序中使用Code Barre扫描程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用vs 2012(winform应用程序)的应用程序来扫描产品的代码,并自动检测数据库中的产品名称,我需要如何使用代码条扫描器和我的应用程序来检测自动输入代码的值而不按一个按钮?

i have created an application with vs 2012(winform application) that scan a code barre of product and automatically detect a name of product from a database , i need how i can use a code bar scanner with my application in order to detect automatically the value of the code without press a button ?

推荐答案

大多数扫描仪都配置为键盘,只要你的应用程序坐与焦点在一个文本框或类似的条形码数据应该自动输入。

如果这不是你需要的,通常可以改变他们的工作方式(比如)提供一个开始和您的应用程序可以识别的最终代码 - 购买需要与设备制造商合作。



一旦你有条形码,很明显你如何使用它看起来在您的数据库中使用相关产品并使用它。
Most scanners are configured to act as a keyboard, so as long as your application is "sitting" with the focus in a text box or similar the barcode data should be entered automatically.
If that isn't what you need, it is normally possible to change the way they work to (say) provide a start and end code your application can recognise - buy that needs to be worked out with the equipment manufacturer.

Once you have the barcode, it's pretty obvious how you use that to look up the related product in your DB and work with it.


这很简单 - 请参考我的一个ous回答了同样的问题:如何使用条形码扫描仪阅读条形码 [ ^ ]



除了链接的答案:大多数条形码扫描仪默认会自动将返回字符附加到扫描的条形码上,否则可以按照这种方式进行配置(或添加不同的字符或不附加字符)。



评论后编辑:

如果您将条形码扫描器配置为附加返回字符,则可以使用此类代码处理扫描的条形码:

It's really simple - please refer to one of my previous answers to the same kind of question: How to read a barcode using a barcode scanner[^]

In addition to the linked answer: Most barcode scanners automatically append a return character to the scanned barcode by default, otherwise it can be configured that way (or to append a different or no character).

Edit after comment:
If you have your barcode scanner configured to append a return character then you can use this kind of code to process a scanned barcode:
public Form1()
{
    InitializeComponent();

    BarcodeTextBox.KeyDown += BarcodeTextBoxKeyDown;
}

private void BarcodeTextBoxKeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter) // wait for the return character
    {
        string barcode = BarcodeTextBox.Text;
        BarcodeTextBox.Text = "";
        e.Handled = true;

        // todo: do something with barcode
    }
}


这篇关于如何在C#应用程序中使用Code Barre扫描程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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