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