1
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."

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • possible duplicate of [Is it possible to "steal" an event handler from one control and give it to another?](http://stackoverflow.com/questions/293007/is-it-possible-to-steal-an-event-handler-from-one-control-and-give-it-to-anoth) – Hans Passant Jan 17 '13 at 16:51
  • 1
    As a work around I hidden the button and added another. –  Jul 25 '18 at 08:55

1 Answers1

-1

You could use this:

RemoveHandler Obj.Ev_Event, AddressOf EventHandler

MSDN Documentation

SysDragon
  • 9,692
  • 15
  • 60
  • 89
  • but i do not know the EventHandler's name. And when I try to get the list of all eventhadlers with "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." –  Jan 18 '13 at 06:28
  • Any way i need the EventHandler that handles the click event on the CrystalreportViewer print Button. Do you know anything about that? –  Jan 18 '13 at 06:34