Handling events

S

SOS

Hi guys,
i need to create some of my controls dynamically.
for example i want to create a button on my web form with this code :

Dim btnMyButton As New Button
Me.Controls.Add(btnMyButton)

how can i handle the events of this button ?

Thanx
 
N

Nauzad Kapadia

using the AddHandler Keyword.

AddHandler btnMyButton.Click, Addressof MyEventHandler

Where myEventHandler is the name of the function that you will create to
handle the event.

Just make sure that the function is declared using the following syntax
Private Sub myEventHandler (sender as object, e as System.EventArgs)

Regards,
Nauzad Kapadia [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top