In a WinForm C# application I have a Barcode_textbox. In TextChanged
event I have an SQL query to check for the TextBox.Text value in the database which is the barc
You could use the Validating event to check the content of the TextBox.
Your user will be required to press the TAB key to change the current focus from the TextBox to the next control following the taborder and the validating event will be triggered
private void textBox_BarCode_Validating(object sender, CancelEventArgs e)
{
// Code to check the barcode on the SQL database....
if(!ValidBarCode(textBox1.Text))
{
// Cancel the event and select the text to be corrected by the user.
e.Cancel = true;
textBox1.Select(0, textBox1.Text.Length);
}
}
Suppose that the next control is the command that executes something using the Barcode inserted (Add)(or a textBox to insert the quantity of the item described by the barcode). After a while all the operation becomes a very natural data entry processing