Click here to Skip to main content
15,919,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
currently, i'm working on the c# winform application
i have 3 textboxes on my screen
1-Product Name (Textbox)
2-Price (Textbox)
3-Barcode (Textbox)
now I want if my focus on the product name or any other control but once I scan the barcode then the barcode will be written inside the 3-Barcode Text box.
is it possible if yes then How?

What I have tried:

i have no idea how can i do this
Updated 29-Oct-21 22:16pm

1 solution

It's possible - with most scanners - but it need you to contact your scanner manufacturer and find out how to set a specific "lead in" and "tail out" sequence for each scan.

The problem is that scanners generally come configured to act as a keyboard - so the data that is scanned goes straight into the standard keyboard data buffer and Windows doesn't keep track of which keyboard provided which key. So all keyboards on the system feed data to the same buffer and you can't tell at all where a keystroke came from.

When you have the sequences configured, you preview the keyboard input at form level looking for the "lead in" sequence, set the focus to the appropriate textbox, and start looking for the "tail out" sequence. When you get that, you can process the whole barcode text from the textbox content.

But we can't tell you how to do that - it is different for each scanner manufacturer (and sometimes different by model as well).
Share this answer

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