|
| |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
方式一:(有光标闪烁,输入、删除等操作无效) Text1.Locked = True 方式二:(无光标闪烁,不能输入、删除,界面变色、文字反白) Text1.Enabled = False 方式三:(有光标闪烁,可删除,不能输入) 此法用两个API函数,略为复杂些。请在标准工程添加两个按钮和一个文本框: Option Explicit Private Declare Function GetWindowLong Lib \"user32\" Alias \"GetWindowLongA\" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib \"user32\" Alias \"SetWindowLongA\" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Const GWL_STYLE = (-16) Const ES_NUMBER = &H2000& Public Sub SetNumber(NumberText As TextBox, Flag As Boolean) Dim CurrentStyle As Long, NewStyle As Long \\\'返回正常样式 CurrentStyle = GetWindowLong(NumberText.hwnd, GWL_STYLE) If Flag Then CurrentStyle = CurrentStyle Or ES_NUMBER Else CurrentStyle = CurrentStyle And (Not ES_NUMBER) End If \\\'设置新样式 NewStyle = SetWindowLong(NumberText.hwnd, GWL_STYLE, CurrentStyle) NumberText.Refresh \\\'刷新 End Sub Private Sub Command1_Click() SetNumber Text1, True Text1.SetFocus End Sub Private Sub Command2_Click() SetNumber Text1, False Text1.SetFocus End Sub Private Sub Form_Load() Command1.Caption = \"禁止输入\" Command2.Caption = \"可以输入\" End Sub 返回类别: 教程 上一教程: Microsoft .NET与J2EE的比较[E] 下一教程: 用c#写的asp+域名查询程序 您可以阅读与"禁止在TextBox中输入"相关的教程: · ASP.NET中输入文本的HTML解析办法 · 在RichTextBox控件加入图片 · Biztalk Server简介(出版物作品,禁止转载,假如出现法律问题,文责自负) · ASP.NET学习手记:验证用户表单输入 · 当你的Studio.NET出现"Automation Server Cannot Create Object"时,禁止添加页面及类文件时的解决方案~~ |
| 快精灵印艺坊 版权所有 |
首页 |
||