Private Sub SetupToolStrip(ByVal ControlCollection As Control.ControlCollection)
For Each aControl As Control In ControlCollection
If TypeOf aControl Is System.Windows.Forms.ToolStrip Then
Dim ToolBar As System.Windows.Forms.ToolStrip = DirectCast(aControl, System.Windows.Forms.ToolStrip)
For Each Item As System.Windows.Forms.ToolStripItem In ToolBar.Items
If Item.ToolTipText = "Print Report" Then
AddHandler Item.Click, AddressOf VerificDacaPrintam
End If
Next
End If
If Not aControl.Controls Is Nothing Then SetupToolStrip(aControl.Controls)
Next
End Sub
But I want to remove all the events of Item.Click
before I do:
AddHandler Item.Click, AddressOf VerificDacaPrintam
And the following does not work:
Item.Click = Nothing
Dim del As [Delegate]() = Item.Click.GetInvocationList()
It says that "Click is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event."