Vb.net 如何从事件中删除所有处理程序?
但我想删除Vb.net 如何从事件中删除所有处理程序?,vb.net,crystal-reports-2010,Vb.net,Crystal Reports 2010,但我想删除项的所有事件。请单击,然后执行以下操作: Private Sub SetupToolStrip(ByVal ControlCollection As Control.ControlCollection) For Each aControl As Control In ControlCollection If TypeOf aControl Is System.Windows.Forms.ToolStrip Then
项的所有事件。请单击,然后执行以下操作:
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
以下情况不起作用:
AddHandler Item.Click, AddressOf VerificDacaPrintam
它表示“单击是一个事件,不能直接调用。请使用“RaiseEvent”语句来引发事件。”您可以使用以下方法:
Item.Click = Nothing
Dim del As [Delegate]() = Item.Click.GetInvocationList()
可能重复的作为解决方法我隐藏了按钮并添加了另一个。但我不知道EventHandler的名称。当我尝试使用“Dim del As[Delegate]()=Item.Click.GetInvocationList()”获取所有EventHadler的列表时,它会说“Click是一个事件,不能直接调用。使用'RaiseEvent'语句引发事件。”我需要在CrystalreportViewer打印按钮上处理Click事件的EventHandler。你知道那件事吗?
RemoveHandler Obj.Ev_Event, AddressOf EventHandler