本文介绍了从扫描仪条形码读取数据时如何移除对焦按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从条形码扫描器读取数据到窗体。
i可以毫无问题地读取数据成功
我的问题是,如果我把按钮放在形式上它专注于它而不是读取数据
这样如何放置按钮并将焦点移到它上面这实际上是我的问题我需要
求解。
I need to read data from bar code scanner to windows form .
i can read data success without any problem
my problem is if i put the button in form it focus on it and not reading data
so that how to put button and remove focus on it this is actually my problem i need to
solve .
public partial class Form1 : Form
{
DateTime _lastKeystroke = new DateTime(0);
List<char> _barcode = new List<char>(10);
public Form1()
{
InitializeComponent();
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
if (elapsed.TotalMilliseconds > 100)
_barcode.Clear();
// record keystroke & timestamp
_barcode.Add(e.KeyChar);
_lastKeystroke = DateTime.Now;
// process barcode
if (e.KeyChar == 13 && _barcode.Count > 0)
{
string msg = new String(_barcode.ToArray());
label1.Text = msg;
//queryData(msg);
_barcode.Clear();
}
}
}
}
我尝试了什么:
What I have tried:
how to remove focus on button when reading data from scanner barcode
推荐答案
textBox1.Focus();
这篇关于从扫描仪条形码读取数据时如何移除对焦按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!