Possible Duplicate:
VB.NET RemoveHandler & Anonymous Methods
If I add an event handler like this:
AddHandler s.Click, AddressOf Panel1_Click
How can I can then remove the event handler?
Private Sub Panel1_click(ByVal sender As Object, ByVal e As System.EventArgs)
' Remove code
End Sub
Go to the objects tab, view the Document object (don't click on edit) and scroll down to Event Handlers. Select the one to delete and press delete.
Only one event handler can be assigned for every event in an element. If needed the handler can be replaced by assigning another function to the same property. Below we show how to set a simple greet() function for the click event using the onclick property.
In programming, an event handler is a callback routine that operates asynchronously once an event takes place. It dictates the action that follows the event. The programmer writes a code for this action to take place. An event is an action that takes place when a user interacts with a program.
From the Class Name drop-down list at the top of the Code Editor, select the object that you want to create an event handler for. From the Method Name drop-down list at the top of the Code Editor, select the event. Visual Studio creates the event handler and moves the insertion point to the newly created event handler.
You can do so using the RemoveHandler
operator, as such:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With