为数据库表名称创建字母数字加下划线的掩码文本框 [英] Creating an Alphanumeric plus underscore Masked Text Box for DB Table Names
问题描述
我想为数据库表名称创建一个输入框.因此,我不想允许使用空格或特殊字符,但是我希望允许使用下划线,数字或字母.
我尝试将以下内容放入按键事件中
Hi,
I want to create an input box for database table names. As such I don''t want to allow spaces or special characters but I do want to allow the Underscore, numbers or letters.
I tried putting the following into the keypress event
Dim allowedChars As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
If allowedChars.IndexOf(e.KeyChar) = -1 Then
' Invalid Character
e.Handled = True
End If
真的很近,但是我发现退格键不起作用,这让我担心用户的接受...
所以我是在正确的轨道上,但需要更多调整才能正常工作,还是我不知道其他解决方案? (我对.Net还是很陌生)
谢谢.
which was really close but I found that the backspace key wouldn''t work which made me nervous about user acceptance ...
So am I on the right track but need more tweaking to get this working or is there another solution that I''m not aware of? (I''m still pretty new to .Net)
Thanks.
推荐答案
您尝试过类似的东西吗?
Did you tried something like this?
Collapse | Copy Code
Dim allowedChars As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
If allowedChars.IndexOf(e.KeyChar) = -1 Or e.KeyChar = Convert.ToChar(Keys.Back) Then
' Invalid Character
e.Handled = True
End If
干杯!
Cheers!
这篇关于为数据库表名称创建字母数字加下划线的掩码文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!