我有一些自动创建一些ActiveX组合框的vba代码。为了处理他们的事件,我用CComboEvent对象填充一个全局Collection(我写的自定义类,见下文),每个组合框都有一个。 CComboEvent对象应该处理事件。虽然下面的代码中的cbx_Change()按预期工作,但cbx_GotFocus()不会触发。
我觉得我在监督某事,有人可以帮忙吗?
谢谢
Option Explicit
Public WithEvents Cbx As MSForms.ComboBox
Private Sub Cbx_Change()
' TODO: Filter data that is shown in ListFillRange
' For now just show that the event fires:
MsgBox Cbx.Value ' This works as expected on every key stroke
End Sub
Private Sub Cbx_GotFocus()
MsgBox "FOCUS!" ' Never shown
' Open the dropdown list
Cbx.ListFillRange = "A1:A11"
Cbx.DropDown
End Sub