How can i filter a Microsoft.NET 2.0 Text box to only take USB characters?

和自甴很熟 提交于 2019-12-13 05:46:52

问题


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 ?

Thanks.

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 .


回答1:


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

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



来源:https://stackoverflow.com/questions/4487153/how-can-i-filter-a-microsoft-net-2-0-text-box-to-only-take-usb-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!