Hi,
I have a little(?) problem with an EventHandler. I create 79 Buttons in a For Loop and add an eventhandler to each of them. My code looks like this:
It works almost, but the event handler only fires once - sometimes. Sometimes it doesn´t work. Can anybody help me and post some code or can tell me what the problem is?
EDIT: It´s an Outlook Add-In Created with Visual Studio 2005
I have a little(?) problem with an EventHandler. I create 79 Buttons in a For Loop and add an eventhandler to each of them. My code looks like this:
Code:
Public Sub CreateButtons()
For intStartIndex = intStartIndex To 79
oButton = CType(m_PopUp_1.Controls.Add _
(Office.MsoControlType.msoControlButton, Temporary:=False),_
Office.CommandBarButton)
oButton.Caption = intStartIndex
AddHandler oButton.Click, AddressOf oButton_Click
Next
End Sub
Private Sub oButton_Click(ByVal ctrl As Office.CommandBarButton,_
ByRef Cancel As Boolean)
MessageBox.Show(ctrl.Caption)
End Sub
It works almost, but the event handler only fires once - sometimes. Sometimes it doesn´t work. Can anybody help me and post some code or can tell me what the problem is?
EDIT: It´s an Outlook Add-In Created with Visual Studio 2005
Last edited: