主题:求教关于空格键打开COMBOBOX下拉框看不到效果的问题
freefly2
[专家分:0] 发布于 2008-01-13 11:32:00
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
SendKeys "%{DOWN}"
End If
End Sub
这个代码表示发送alt+down 打开下拉框,(我的机器实验过,如果直接按键这两个可以打开)。但是通过SENDKEYS的方式不行。SENDKEYS发送其他的键都可以有效果的![em1][em1]
回复列表 (共3个回复)
沙发
merry05 [专家分:8920] 发布于 2008-01-13 21:23:00
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
SendKeys "%{DOWN}"
End If
End Sub
Private Sub Form_Load()
Form1.KeyPreview = True
End Sub
板凳
freefly2 [专家分:0] 发布于 2008-01-15 20:23:00
先谢谢你!但是,我粘贴后没有效果的!!
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
SendKeys "%{DOWN}"
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "A"
Combo1.AddItem "B"
Form1.KeyPreview = True
End Sub
[em7]
3 楼
一江秋水 [专家分:9680] 发布于 2008-01-16 12:06:00
在我的机器上你的代码是有效的:
Private Sub Form_Load()
Combo1.AddItem "A"
Combo1.AddItem "B"
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then SendKeys "%{DOWN}"
End Sub
按一次空格,打开下拉框,再按一次就收起,如果你的不能,检查一下在Combo1的KeyUp、KeyDown、Click等事件中是否有相冲突的代码
我来回复