Winform程序扫码条码读取商品数据简单实现|C/S框架网

条码扫描枪就是输入设备,与键盘输入一个原理,在程序中把输入焦点固定在输入框内,扫描条码时自动读取文本,并且自动回车,程序只要处理回车事件(KeyDown)就可以了。

C# Code:
private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
{
//捕获回车键
if (e.KeyCode == Keys.Enter)
{
//获取条码资料
string barcode = txtBarcode.Text.Trim();
if (!String.IsNullOrEmpty(barcode))
{
//条码处理程序
}
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
{
//捕获回车键
if (e.KeyCode == Keys.Enter)
{
//获取条码资料
string barcode = txtBarcode.Text.Trim();
if (!String.IsNullOrEmpty(barcode))
{
//条码处理程序
}
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761


版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网