am having an issue related to barcode scanner input and richtextbox. This is whats happening right now. I move my cursor into the textbox, scan a barcode. The output comes in the rich textbox and I press a button to filter the input from the barcode scanner on the press of that button and display the filtered string in the richtextbox. This looks kind of untidy. I want that right after the barcode scanner gets the input I display the filtered text rightaway. I already wrote the filtering algorithm. It is just that its being applied on the click of the button. I tried playing with textchanged event but it is not helping me. Kindly suggest me a way to handle the situation. code example would be great.
Asked
Active
Viewed 755 times
1
-
1Barcode scanners typically end the input with a line feed/ carriage return or other similar character. Use the text changed event to check for that and run your filter if you find it. – Tim Williams Feb 24 '14 at 06:13
-
u mean a barcode scanner ends up its output with an empty line?? – user3345361 Feb 24 '14 at 06:17
-
Enter key wont fire TextChanged event. http://stackoverflow.com/questions/11984238/detect-enter-key-c-sharp – Panu Oksala Feb 24 '14 at 06:18
-
brings me back to the same place. any suggestions to help myself sir – user3345361 Feb 24 '14 at 06:22
-
just checked through the debugger. textchanged event is being fired on enter keypress! – user3345361 Feb 24 '14 at 06:24
1 Answers
0
TextChanged is a event which you should use. Could you put some kind of length validation into TextChanged event and automatically filter read message when length is correct?
If barcode scanner sends line change ("ENTER") after barcode is read, you could call filterting when "enter" is read. This can be handled at "KeyPress" event. Add "CheckEnter" event handler to textbox which will contain read barcode.
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnter);
Now we have to create a method called CheckEnter.
private void CheckEnter(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
// We got an enter key. Call TextBox filtering here.
}
}

Panu Oksala
- 3,245
- 1
- 18
- 28
-
-
-
its giving method not implemented exception. I generated the function in designer file of the form! any clues? – user3345361 Feb 24 '14 at 07:03
-
and yes my scanner does press enter key on every scanned output. Looks like ur idea is going to work here – user3345361 Feb 24 '14 at 07:04
-
this is not going to work. As my scanner is already pressing enter couple of times in the scanned barcode :( – user3345361 Feb 24 '14 at 07:15
-
Oh. so problem is still valid? I think you figured out that NotImplementedException already? – Panu Oksala Feb 24 '14 at 07:54
-
1I did. This logic is working fine for barcodes which have a single line encoded. for my barcode presses enter at the end of every output. However in my case(reading national identity) the encoded barcode has already 4 lines of information with an enter key pressed after everyline :( – user3345361 Feb 24 '14 at 08:12