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

但我想Item.Click在我做之前删除所有事件:

AddHandler Item.Click, AddressOf VerificDacaPrintam

以下不起作用:

Item.Click = Nothing       

Dim del As [Delegate]() = Item.Click.GetInvocationList() 

它说“点击是一个事件,不能直接调用。使用'RaiseEvent'语句来引发事件。”

4

1 回答 1

-1

你可以使用这个:

RemoveHandler Obj.Ev_Event, AddressOf EventHandler

MSDN 文档

于 2013-01-17T15:30:05.773 回答