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

首頁 > 開發 > 綜合 > 正文

VB制作的可以限制輸入的文本框

2024-07-21 02:21:10
字體:
來源:轉載
供稿:網友
通過繼承textbox,添加了一個validtext屬性,用來獲取和設置有效的文本輸入

還有一個editable屬性,決定文本框是否支持退格編輯。

我是剛學習vb.net,希望和大家交流,我得qq:36745349

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
end class

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太和县| 乐清市| 禹城市| 治多县| 嘉义县| 桐庐县| 股票| 都兰县| 那曲县| 密山市| 长宁区| 来安县| 高州市| 安陆市| 金湖县| 湘西| 中牟县| 望都县| 东兰县| 富源县| 甘南县| 积石山| 横山县| 合肥市| 中西区| 石狮市| 吉隆县| 美姑县| 焉耆| 闻喜县| 盈江县| 保山市| 沈阳市| 英德市| 宁强县| 莱西市| 普定县| 郴州市| 兖州市| 苍溪县| 苍溪县|