addhandler question

kcwallace

Centurion
Joined
May 27, 2004
Messages
175
Location
Austin, TX
I have a routine in my application that builds a form on the fly from input from a database. Everything works great.

I have added another form that is also created on the fly, and it too works great.

The thing this is, the code is nearly identical to build each form.

I can easily write a routine to build generically build a form. However, I need to add buttons that require events.

What I would like to know if anyone knows how to pass a delegate/routine as a parameter of a routine so addHandler can use it.
 
Visual Basic:
Public Sub Example()
    'Get function pointer
    Dim myDelegate As EventHandler = AddressOf SomeForm.Button1_Click
    'Pass it to a function
    MoreExample(myDelegate)
End Sub
 
Public Sub MoreExample(ByVal Handler As EventHandler)
    'Accept function pointer and use it
    AddHandler Button1.Click, Handler
End Sub
 
Back
Top