如何过滤Microsoft.NET 2.0文本框以仅使用USB字符? [英] How can i filter a Microsoft.NET 2.0 Text box to only take USB characters?

查看:90
本文介绍了如何过滤Microsoft.NET 2.0文本框以仅使用USB字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows窗体2.0中使用Microsoft.NET文本框,并使用C#从基于USB的条形码扫描仪获取数据.用户不希望文本框接受来自键盘的输入.我如何应用过滤器,以便在此会话期间仅接受来自USB的输入,并禁用键盘?

I am using a Microsoft.NET text box in Windows Forms 2.0 using C# for data from a USB based Bar code scanner. The user does not want the text box to accept inputs from keyboard. How can i apply a filter such that only inputs from the USB are accepted and the keyboard disabled during this session ?

谢谢.

一小时后添加评论:我在我需要研究的.

Comment added one hour after: I got some thing on this and this which i need to study.

对于那些想知道为什么需要这种冗余的用户,用户还希望获得一个选项来将键盘配置为活动/不活动.

To those of you who want to know why this redundancy, the user also wants an option to configure the Keyboard to be active / inactive .

推荐答案

您不能.条形码扫描仪是一个键盘(种类繁多).它以与键盘完全相同的方式输入文本字符.

You can't. The bar code scanner IS a keyboard (of sorts). It inputs text characters in the exact same way as a keyboard.

我想一个选择是断开物理键盘的连接.除此之外,您可以根据硬件序列号尝试"阻止输入.但这是一个问题:a)它不可扩展,并且b)如果您的扫描仪死了,则您必须尝试使用​​您的软件.

I suppose one option would be to disconnect the physical keyboard. And barring that, you could "try" to block input based on hardware serial number. But the problem with this is a) that it's not scalable, and b) if your scanner ever dies, you have to monkey with your software.

还请记住,条形码只是人类可读字符的线条表示.这样,如果扫描仪无法读取条形码,您可以手动在条形码下方输入微小数字.

Also remember, bar codes are just line representations of human readable characters. That way you can enter the tiny numbers below the barcode manually if your scanner can't read them.

我会后退并告诉老板这是个坏主意(当然取决于请求的上下文).

I'd push back and tell the boss that's a bad idea (depending on the context of the request of course).

这篇关于如何过滤Microsoft.NET 2.0文本框以仅使用USB字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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