在richtextbox版权中显示条形码扫描仪输出(Showing up barcode scanner output in richtextbox rightsaway)

编程入门 行业动态 更新时间:2024-10-27 10:21:53
在richtextbox版权中显示条形码扫描仪输出(Showing up barcode scanner output in richtextbox rightsaway)

我遇到了与条形码扫描仪输入和richtextbox相关的问题。 这是现在发生的事情。 我将光标移动到文本框中,扫描条形码。 输出来自富文本框,我按下按钮以按下该按钮过滤条形码扫描器的输入,并在richtextbox中显示过滤后的字符串。 这看起来有点凌乱。 我希望在条形码扫描仪获得输入后立即显示过滤后的文本。 我已经编写了过滤算法。 它只是在点击按钮时应用它。 我尝试使用textchanged事件,但它没有帮助我。 请建议我一种处理这种情况的方法。 代码示例会很棒。

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是您应该使用的事件。 你能在TextChanged事件中加入某种长度验证,并在长度正确时自动过滤读取消息吗?

如果条形码扫描器在读取条形码后发送换行(“ENTER”),则可以在读取“enter”时调用filterting。 这可以在“KeyPress”事件中处理。 将“CheckEnter”事件处理程序添加到包含读取条形码的文本框中。

this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnter);

现在我们必须创建一个名为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. } }

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

更多推荐

本文发布于:2023-07-09 14:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1087163.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条形码   扫描仪   版权   richtextbox   Showing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!