Barcode Scanner in C#

SaltyDawg

Newcomer
Joined
Mar 19, 2008
Messages
5
I have an application in C# which uses a dialog box with a textbox and a button to submit. A barcode scanner is used input the data. Currently after the scan the user must use the mouse to click the submit button.

What can I do to submit to data automatically after scanning. I know there is something about a carriage return character, but I have no idea what to do. If I scan the barcode with any other program (even WordPad) it would carriage return to the next line, but its not working in my C# app. Is there something I need to add to my code or a property I need to set to the textbox or button? Thanks.
 
Last edited:
Below is the event when doing a kepress And you will also need to change the code in Designer Code for the event handler of the test box


C#:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
		{
			if(e.KeyChar == 13)
			{
				MessageBox.Show("ENTERED");// You code here
			}
		}

Change this
C#:
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);

to this
C#:
	this.textBox1.KeyPress += new KeyPressEventHandler(this.textBox1_KeyPress);
 
the KeyPressEventHandler method is not being recognized.

Tried:
this.txtScanUserId.KeyPress += new System.KeyPressEventHandler(this.txtScanUserId_KeyPress);

By the way, like that Gandhi quote one of my favorites I try to live by.
 
after "new" take the system out. It is just KeyPressEventHandler

Yes, on the quote I heard it one day on Criminal Minds. When they start an episode, they do a famous quote and I heard that. I Have always thought this way, but the quote was the perfect way to say it.
 
Got it:

I tried System.Windows.Forms.KeyPressEventHandler and it works.

Thanks alot for your help

I guess if I had declared "using System.Windows.Forms" it at the top KeyPressEventHandler would have worked
 
Got it:

I tried System.Windows.Forms.KeyPressEventHandler and it works.

Thanks alot for your help

I guess if I had declared "using System.Windows.Forms" it at the top KeyPressEventHandler would have worked


AH yes, I have the "using.." at the top. When I start a new program it put it in.
 
Back
Top