请问关于TextBox的两个问题??

kgdlnyq 2003-08-25 12:43:55
1、TextBox控件为什么不能用CTRL+A全选,不是编辑状态的连CTRL+C和CTRL+V也不能!
2、怎样实现用程序选定TextBox里面的全部内容
3、怎样实现出输入一个TexBox的内容后,一回车就自动按一个按钮不用另外按鼠标!
...全文
38 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
kgdlnyq 2003-08-26
  • 打赏
  • 举报
回复
谢谢各位的回答!!
dongrui121 2003-08-25
  • 打赏
  • 举报
回复
都说完了!
pigpag 2003-08-25
  • 打赏
  • 举报
回复
把Ctrl+A的功能做在菜单里面也可以。
hxy2003 2003-08-25
  • 打赏
  • 举报
回复
来晚啦,还是楼上的比较好
射天狼 2003-08-25
  • 打赏
  • 举报
回复
'1.TextBox不支持CTRL+A快捷,要想实现的话只能自己做,如下所示:

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = 2 And KeyCode = 65 Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End If
End Sub

'2.
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
'Text1.SetFocus
'3.
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
Command1.Value = True '相当于用鼠标点击
End If
End Sub
Apple200228 2003-08-25
  • 打赏
  • 举报
回复
同意rainstormmaster(rainstormmaster) 的做法。
zqfleaf 2003-08-25
  • 打赏
  • 举报
回复
或command2.default=true
evbsky 2003-08-25
  • 打赏
  • 举报
回复
呵,来晚了!
rainstormmaster 2003-08-25
  • 打赏
  • 举报
回复
Private Sub Command1_Click() '实现全选
Dim s As String
s = "123456789abcdefg"
Text1.Text = s
Dim i As Long
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)

End Sub

Private Sub Command2_Click()
MsgBox "ok"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then '如果输入回车键
Command2_Click
End If
End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧