Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Go Beavs!!!
  • Leaders
Posted
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

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...