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'语句来引发事件。”