TEXTBOX 用户控件,无法响应回车,大家帮我看下
时间:2011-08-12
来源:互联网
Option Explicit
Private Sub UserControl_Initialize()
UserControl.BackColor = 0
UserControl.ScaleMode = vbPixels
Text1.BorderStyle = 0
End Sub
Private Sub UserControl_Resize()
Text1.Move 1, 1, UserControl.ScaleWidth - 2, UserControl.ScaleHeight - 2
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Text1.Text = PropBag.ReadProperty("Text")
UserControl.BackColor = PropBag.ReadProperty("BorderColor")
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Text", Text1.Text)
Call PropBag.WriteProperty("BorderColor", UserControl.BackColor)
End Sub
Public Property Get Text() As String
Text = Text1.Text
End Property
Public Property Let Text(ByVal New_Value As String)
Text1.Text = New_Value
UserControl.PropertyChanged "Text"
End Property
Public Property Get BorderColor() As OLE_COLOR
BorderColor = UserControl.BackColor
End Property
Public Property Let BorderColor(ByVal New_Value As OLE_COLOR)
UserControl.BackColor = New_Value
UserControl.PropertyChanged "BorderColor"
End Property
这上面是我自定义的用户控件
Private Sub text1_KeyPress(KeyAscii As Integer)
MsgBox "这里捕捉不到"
End Sub
为什么KeyPress这个属性在这就失效了呢?是不是在用户控件里还需要加入什么代码?
Private Sub UserControl_Initialize()
UserControl.BackColor = 0
UserControl.ScaleMode = vbPixels
Text1.BorderStyle = 0
End Sub
Private Sub UserControl_Resize()
Text1.Move 1, 1, UserControl.ScaleWidth - 2, UserControl.ScaleHeight - 2
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Text1.Text = PropBag.ReadProperty("Text")
UserControl.BackColor = PropBag.ReadProperty("BorderColor")
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Text", Text1.Text)
Call PropBag.WriteProperty("BorderColor", UserControl.BackColor)
End Sub
Public Property Get Text() As String
Text = Text1.Text
End Property
Public Property Let Text(ByVal New_Value As String)
Text1.Text = New_Value
UserControl.PropertyChanged "Text"
End Property
Public Property Get BorderColor() As OLE_COLOR
BorderColor = UserControl.BackColor
End Property
Public Property Let BorderColor(ByVal New_Value As OLE_COLOR)
UserControl.BackColor = New_Value
UserControl.PropertyChanged "BorderColor"
End Property
这上面是我自定义的用户控件
Private Sub text1_KeyPress(KeyAscii As Integer)
MsgBox "这里捕捉不到"
End Sub
为什么KeyPress这个属性在这就失效了呢?是不是在用户控件里还需要加入什么代码?
作者: yejian520 发布时间: 2011-08-12
其它键能捕获吗?
作者: c_cyd2008 发布时间: 2011-08-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28