Click here to Skip to main content
15,910,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am making an inventory application using c#. The application needs to be driven by the Barcode Scanner ie. whenever a barcode is scanned, i need it to spawn an event so that it can take the necessary action. I have tried using a TextChanged event in a textbox, but it spawns an event for each character in the string rather than one for the whole string. I am using a USB Barcode Scanner. Any help would be appreciated.
Posted

Did you see if there is an event that indicates when the scan is complete? That would probably be in the barcode reader's driver or interface object. If there is, you can wait for that event to be fired, and *then* check the textbox for data. Or maybe the scanner sends a special character to indicate that it's done. It's kinda hard to say because you're the guy with the scanner.
 
Share this answer
 
v2
Another note, consider if the text box is the only UI element that can handle the input from the barcode reader. Depending on the situation it may be reasonable to handle the barcode no matter what object has the focus. If this is needed, you could wire the keypress (or similar) event correctly at form/window/etc level.
 
Share this answer
 
I had the same situation for a library app I developed. I had the scanner add the <enter> key code to the end of the scanned code. That way, I would handle just this event in the textbox and this would let the user either use the scanner or type the value in the box and press <enter> without altering the code. Of course, the textbox had to have the focus in this case.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900