国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

可以限制中文輸入的文本框

2024-07-21 02:21:09
字體:
來源:轉載
供稿:網友
根據網友提的意見,大家都需要限制中文輸入,今天,我試驗了一下,找了一個辦法限制中文輸入,測試已經通過,大家也自己試一下吧,有什么意見繼續提,如果愿意加我的qq:36745349



這個是在昨天的基礎上做的更改,測試已經滿足大家的要求,如果誰有更好的辦法也請交流一下

下面是代碼:

'sunnyxing2004-04-01最后修改
public class mytextbox
inherits system.windows.forms.textbox
private m_strvalidtext as string = "0123456789.+-" & chr(13).tostring
private m_blneditable as boolean = true

#region " windows 窗體設計器生成的代碼 "

public sub new()
mybase.new()
'該調用是 windows 窗體設計器所必需的。
initializecomponent()

'在 initializecomponent() 調用之后添加任何初始化

end sub

'usercontrol1 重寫 dispose 以清理組件列表。
protected overloads overrides sub dispose(byval disposing as boolean)
if disposing then
if not (components is nothing) then
components.dispose()
end if
end if
mybase.dispose(disposing)
end sub

'windows 窗體設計器所必需的
private components as system.componentmodel.icontainer

'注意: 以下過程是 windows 窗體設計器所必需的
'可以使用 windows 窗體設計器修改此過程。
'不要使用代碼編輯器修改它。
<system.diagnostics.debuggerstepthrough()> private sub initializecomponent()
components = new system.componentmodel.container
end sub

#end region

private sub mytextbox_keypress(byval sender as object, byval e as system.windows.forms.keypresseventargs) handles mybase.keypress
dim strlocalstring as string
if editable then
strlocalstring = m_strvalidtext & chr(8).tostring
else
strlocalstring = m_strvalidtext
end if
if ucase(strlocalstring).indexof(ucase(e.keychar)) < 0 then
e.handled = true
beep()
else

end if
end sub
public property validtext() as string
get
return m_strvalidtext
end get
set(byval value as string)
m_strvalidtext = value
end set
end property
public property editable() as boolean
get
return m_blneditable
end get
set(byval value as boolean)
m_blneditable = value
end set
end property
public sub checktext(byval sender as object, byval e as system.eventargs) handles mybase.textchanged
dim cha as char
try
cha = ctype(me.text.substring(me.selectionstart - 1, 1), char)
if m_strvalidtext.indexof(cha) < 0 then
me.text = me.text.remove(me.selectionstart - 1, 1)

end if
catch ex as exception

end try


end sub

end class


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湖州市| 德保县| 芦溪县| 仁化县| 涞水县| 勃利县| 新乐市| 大方县| 景德镇市| 米脂县| 虎林市| 遂平县| 萨嘎县| 兴国县| 天水市| 溧阳市| 阳高县| 大名县| 金湖县| 突泉县| 双辽市| 高邑县| 九龙坡区| 乐平市| 黑龙江省| 皮山县| 商城县| 太原市| 潞西市| 达拉特旗| 遂宁市| 昂仁县| 九龙城区| 嘉定区| 河北区| 浮山县| 闽侯县| 特克斯县| 黄平县| 高碑店市| 达孜县|