如果我添加这样的事件处理程序:
AddHandler s.Click, AddressOf Panel1_Click
我怎样才能删除事件处理程序?
Private Sub Panel1_click(ByVal sender As Object, ByVal e As System.EventArgs)
' Remove code
End Sub
答案 0 :(得分:16)
您可以使用RemoveHandler
运算符执行此操作:
Private Sub Panel1_click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim panel As Panel = CType(sender, Panel)
RemoveHandler panel.Click, AddressOf Panel1_Click
End Sub
答案 1 :(得分:5)
与添加它的方式相同:
RemoveHandler s.Click, AddressOf Panel1_Click