如何在文本框中阅读? [英] how to read in text box ?

查看:94
本文介绍了如何在文本框中阅读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从文本框中的条形码扫描仪中读取并将其添加到数据库中,然后在下次读取时删除上一个读数,而新的读数出现在文本框中

how can i read from barcode scanner in text box and add it in data base then when i read next time the previous reading is deleted and the new one appears in text box

推荐答案

检查onRead上是否有条形码或类似内容.
如果您有类似的内容,则一旦触发,您可以清除文本框.

也可以用另一种方式来完成.在将条形码文本放入框中之前,请清除文本框-但这需要查看您的代码.
Check if if there is a barcode onRead or something similar.
If you have something like this, as soon as it fires, you can clear the textbox.

It could also be done in another way. Clear your textbox just before you place your barcode text into the box - but for that your code needs to be seen.


您可以尝试以下操作

you could try this

private void textBox1_TextChanged(object sender, EventArgs e)
{
// your DB stuff here...
MessageBox.Show(string.Format("{0} entered in database", textBox1.Text));
this.ActiveControl = textBox1;
textBox1.SelectAll();
}


我看了一下用户手册.扫描程序正在发送击键.它发送的击键是输入"键.
我没有发现的是,这是否是默认配置.但是通过扫描手册中的一些条形码进行配置非常容易.
假设将"enter"键配置为最后一个符号,这可能是使用textBoxKeyDown事件的解决方案.

I had a look at the user manual. The scanner is sending keystrokes. The keystroke it sends is the ''enter'' key.
What I didn''t find out is, whether this is default configuration or not. But it is quite easy to configure by scanning some barcodes from the manual.
Assumig that ''enter'' key is configured as last sign, this might be your solution with using the KeyDown event of the textBox.

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        // Your DB stuff
        // MessageBox.Show(textBox1.Text);
        this.ActiveControl = textBox1;
        textBox1.SelectAll();
    }
}


这篇关于如何在文本框中阅读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆