所以我试图让_click事件处理用户窗体上动态添加的文本框控件。
这是我的代码,它使_change事件正常但_click事件不会触发。
' Userform code
Dim myControlsEventH As Collection
Private Sub UserForm_Initialize()
Set myControlsEventH = New Collection
End Sub
Public Sub AddTextbox(myName As String)
'Dim MyTextBox As Object
Dim myTextbox As MSForms.TextBox
Set myTextbox = frmStamps.Controls.Add("Forms.TextBox.1", myName, True)
myTextbox.TextAlign = 2
myTextbox.Font.Size = 18
myTextbox.WordWrap = False
'MyTextBox.AutoSize = True
AdjustSize
Dim txtbxEvent As ctxtbxEventH
Set txtbxEvent = New ctxtbxEventH
Set txtbxEvent.frm = frmStamps
Set txtbxEvent.txtbox = myTextbox
myControlsEventH.Add txtbxEvent
End Sub
' ctxtbxEventH Class code
Public WithEvents txtbox As MSForms.TextBox
Public frm As UserForm
Private Sub txtbox_Click()
Debug.Print "clicked"
End Sub
Private Sub txtbox_Change()
Debug.Print "changed"
End Sub
(BONUS问题(我在哪里可以找到每个MSForms控件的所有可能事件的列表?)