"Go" in C # to determine the scanner input and keyboard input

Source: Internet
Author: User

Ask the question: in the receiving system, often use scanning gun scanning barcode input to the textbox, when the barcode can not be scanned, you need to manually input. If the scanner is input, we will automatically interpret the bar code, and manual input, the final need to add press ENTER to confirm the interpretation of bar code. At this point we will determine whether the input device is a manual or a scanning gun. Try the method:

1. Set the TextBox property to Readonly=true. Result: Could not be entered. 2. Set the property e.handle=true in the KeyPress event of the TextBox. Result: The KeyPress event is also triggered when the scanner is entered, so it cannot be entered. 3. Judge the result in the ValueChanged event of the TextBox. Result: The scanner is also a character input, not one-time to the entire barcode input. Thinking: The scanner actually looks exactly like the keyboard on the input. However, the difference between manual input and scan device input is that the scanning device input speed is relatively fast and the time interval is more average. Experiment: The experimental results prove the beginning inference. Workaround: Private DateTime _dt = DateTime.Now; Defines a member function that is used to hold a point in time private void Textbox1_keypress (object sender, KeyPressEventArgs e) {DateTime TEMPDT = DateTime.Now; Save the button at the point in time TimeSpan ts = TEMPDT. Subtract (_DT); Gets the time interval if (Ts.milliseconds > 50)//determines the interval, if the interval is greater than 50 milliseconds, the textbox is emptied TextBox1.Text = "";d t = TEMPDT;} At this point, the problem solved, I hope you have a better way message exchange: http://www.cnblogs.com/yyknight/archive/2011/10/07/2200399.html

"Go" in C # to determine the scanner input and keyboard input

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.