0
Answer

Combine button_Click into textBox_TextChanged event

Ask a question
TAN WhoAMI

TAN WhoAMI

12y
1k
1
presently, my implementation is such that:
when after some text is entered in a textbox, then a certain button is pressed, and it executes certain events, like store some data in the database, and also clear the textbox for the next input of text.

I want to minimize the steps involved, such that the same sequence of events happen, and do not want to implement the execution of certain events (store data in database and clear the textbox) inside the button_Click event. That is, when user enters some text (or specificially, when the text is captured from a barcode scanner), it would perform that certain events (store data in database and clear the textbox). It would be automated such that user just need to scan the barcode, without pressing any button. It would save certain data to the database, and next clear the textbox, so that next user can come and scan.

which event of the textbox should I use?
I have tried textBox_SelectionChanged, textBox_TextChanged and textBox_SourceUpdated, to bring those code inside button_Click to textBox_SelectionChanged, textBox_TextChanged and textBox_SourceUpdated, but none seem to work. The problem is that I need to clear the textbox after each scan, and that result in no barcode being displayed.

Any good suggestions is greatly appreciated.