문제

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.

도움이 되었습니까?

해결책

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.
       }
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top