How to change a button event?

1

I need to change a .click event of a button by clicking another, but I do not know how to do that. Making common method of Button1.Click = , the program gives me as error.

I'm doing it in VB.NET. How can I change the event settings in this way?

    
asked by anonymous 23.03.2016 / 17:30

2 answers

3

To remove the event Button1_Click

RemoveHandler Button1.Click, AddressOf Button1_Click

To add the event NovoEvento_Click

AddHandler Button1.Click, AddressOf NovoEvento_Click
    
23.03.2016 / 17:39
2

Assuming you have a method:

Sub ButtonClick(sender As Object, e As EventArgs) 

End Sub

You can associate the event Click as follows:

AddHandler Button1.Click, AddressOf ButtonClick
    
23.03.2016 / 17:38