c#USB扫描枪,防止输入框手动输入
作者:互联网
private void txtScan_KeyPress(object sender, KeyPressEventArgs e) { if (string.IsNullOrEmpty(txtScan.Text)) { startInput = DateTime.Now; } if (e.KeyChar == Convert.ToChar(Keys.Enter)) { //判断回车键业务处理 } else { if ((startInput.Ticks + 5000000) > DateTime.Now.Ticks) { txtScan.Text += e.KeyChar; } else { txtScan.Text = ""; } } }
标签:扫描枪,USB,c#,Text,startInput,Ticks,txtScan,DateTime,Now 来源: https://www.cnblogs.com/weifeng123/p/12515554.html