为什么Combo1_DblClick(Index As Integer)事件中 Combo1(Index).ListIndex = -1 不管用
本帖最后由 bcrun 于 2013-06-11 09:48:35 编辑
Private Sub Combo1_DblClick(Index As Integer)
On Error GoTo Errc
Combo1(Index).ListIndex = -1
Exit Sub
Errc:
MsgBox Err.Description
End Sub
Option Explicit
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 10
List1.AddItem i
Next i
List1.ListIndex = 9
End Sub
Private Sub Command1_Click()
On Error GoTo Errc
List1.ListIndex = -1
Exit Sub
Errc:
MsgBox Err.Description
End Sub
Option Explicit
Private Sub Combo1_GotFocus()
On Error GoTo Errc
Combo1.ListIndex = -1
Exit Sub
Errc:
MsgBox Err.Description
End Sub
Private Sub Command1_Click()
MsgBox Combo1.ListIndex
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 10
Combo1.AddItem i
Next i
Combo1.ListIndex = 9
End Sub
[解决办法]
ComboBox 的所有鼠标事件,都定义为在下拉的列表上才生效。你在你的代码 Combo1(Index).ListIndex = -1 处打个断点,你看会停在这里吗?
[解决办法]
对呀!那就不要用 ComboBox Click 之类的事件来做此事。
[解决办法]
COMBO一般用click事件。