Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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.

Edited by SaltyDawg
Posted
Could you not handle the keypress or keyup events for the textbox and if you detect a carriage return then act on it?

 

Sounds good. Now how could I detect the carriage return?

Posted

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

 

 

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

 

Change this

this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);

 

to this

this.textBox1.KeyPress += new KeyPressEventHandler(this.textBox1_KeyPress);

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted

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.

Posted

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.

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted

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

Posted
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.

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...