Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have developed a point of sale application for a retail store in the c# winfrom application.
now my question is my application has a barcode scanning feature like the system will check either the product quantity available in the stock or not by scanning a barcode.
I will set to the textbox text change event my system will first check the barcode is exist in the database or not if the barcode does not exist in the database then my application shows the barcode not existing message.
now the problem is that.
once the user starts the scanning of the barcode application will display the message at the entering of each character in the textbox box I put a condition on the textbox text change event.
please, anyone, give me an idea,
how can I run my function once the barcode scanning is finished.
Note: all my products have different length barcode-like some products have barcodes of 5 characters some products have barcodes of 10 characters.

What I have tried:

private void searchproductnamemetroTextBox_TextChanged(object sender, EventArgs e)
{
    if(Barcodeexist())
    {
      //code of fetch details
    }
    else
    {
     Messagebox.show("Barcode not exist")
    }
}
Posted
Comments
FranzBe 20-Oct-21 6:24am    
Typically in the barcode scanner setup, you have the possibility to define a 'terminating character', which (in my world) is set to <tab>. In my applications the processing begins when the Textbox looses focus. I do not see the benefit of processing the barcode by each character. If you want to keep your TextChanged approach you may want to check if the terminating character was detected.
Fahid Zahoor 21-Oct-21 7:55am    
yes, I like your approach,
I will also set my barcode search start at the leave even of the textbox.
but badly nothing happens.
because I did not set any "terminating character" please can you tell me how to set the terminating character of the barcode scanner?
I'm little bit confused we set the termination caharcers in our barcode device settings or we add terminating character in the barcode No
FranzBe 21-Oct-21 9:13am    
This terminating character, sometimes called 'custom suffix' is not part of the barcode data itself, the scanning device adds it to the barcode data before sending it to the keyboard input. You will need to look into the manual of your barcode scanner to see how it is setup for your device. In case you set this character to 'tab' your barcode device acts similar to a human user, that after entering something in a textbox as well presses 'tab' to go to the next field.
Fahid Zahoor 29-Oct-21 11:14am    
Thank you so much, man. I have done my problem, now it's working fine. I appreciate your help.
Fahid Zahoor 29-Oct-21 11:18am    
i have one more question,
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 but suddenly I scan the barcode then the barcode will be written inside the 3-Barcode Text box.
is it possible if yes then How?

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