How to change a button event?

Asked

Viewed 80 times

1

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

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

  • What have you done? which error is being generated ?

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

2

Assuming you have a method:

Sub ButtonClick(sender As Object, e As EventArgs) 

End Sub

You can associate with the event Click as follows:

AddHandler Button1.Click, AddressOf ButtonClick
  • Bá, I didn’t see that you had answered :P +1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.