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()
它說,「Click是一個事件,不能直接調用,使用'RaiseEvent'語句來引發事件。「
可能重複://計算器.com/questions/293007/is-it-it-it-it-it-to-steal-an-event-handler-from-one-control-and-give-it-to-anoth) –