在combo里如何捕捉上下方向键?

excuseser 2006-05-30 05:46:11
Private Sub Combo1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
If KeyCode = 38 Then aaaagq_ReCall
If KeyCode = 40 Then SendKeys "{TAB}"
End Sub

没有获得上下,请问如何解决?谢谢大家
form.keypreview 设置为true
...全文
109 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
excuseser 2006-05-31
  • 打赏
  • 举报
回复
又努力了一下 发现form.keypreview设为true没关系,我设置了
Combo1(0).Locked = True 如果是false就没问题了。

但是这里的true是我必须的,这个问题该如何解决阿?谢谢大家。
junki 2006-05-31
  • 打赏
  • 举报
回复
'用下面的代码试一试,注意你的Index值:
Private Sub Combo1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Then MsgBox "上"
If KeyCode = 40 Then MsgBox "下"
End Sub
白发程序猿 2006-05-31
  • 打赏
  • 举报
回复
你为什么要把form.keypreview设为true呢,设为false不就没问题了
junki 2006-05-31
  • 打赏
  • 举报
回复
'Combo1.Locked=True,锁定输入数据
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Combo1.Locked = False
End Sub


Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Then MsgBox "上"
If KeyCode = 40 Then MsgBox "下"
Combo1.Locked = True
End Sub
湘王 2006-05-30
  • 打赏
  • 举报
回复
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox KeyCode
If KeyCode = 38 Then MsgBox "上"
If KeyCode = 40 Then MsgBox "下"
End Sub

在我的机器上很好啊,捕捉到了

7,763

社区成员

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

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