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 = ""; } } }