Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
in my windows application c# , i have a textbox named txtItemID
i read id from barcode scanner direct to my textbox
and i check the input values from items in database
my problem is how can read input value from textbox when scanner is finished read ?

because i dont want to go to database every time value insert in textbox ..

please any idea ?

What I have tried:

i try to use textbox change
private void txtItemID_TextChanged(object sender, EventArgs e)
       {
           // select from database every time character input in textbox ;

       }



this way is not useful because i execute query for each character input in textbox
i want to run query only when input finished
Posted

1 solution

Couple of ways:

- If your barcodes always have the same length, wait until the text in the textbox has the right length.

- Configure your scanner to send a special suffix which will allow you to identify the end of the code.

- Start a timer when the first char is entered with a timeout that is sufficiently larger than the delay between single chars sent by the scanner and reset the timer each time another char gets appended. Then only start your database query when the timer has elapsed - that is, after the text hasn't changed for the specified timer interval.

- Don't use a textbox at all but read the barcode scanner's transmission directly at a lower API level - which is what I would do. See here: Using Raw Input from C# to handle multiple keyboards[^] (A typical barcode scanner is basically a keyboard from the system's point of view.)
 
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