I use AddHandler to hook a function to a control event that I dynamically create:
Public Delegate Sub MyEventHandlerDelegate(ByVal sender As Object, ByVal e As System.EventArgs)
Public Sub BuildControl(EventHandler as System.Delegate)
dim objMyButton as new button
AddHandler objMyButton.Click, EventHandler
end Sub
This code throws a runtime exception:
Unable to pass an object of type "MyEventHandlerDelegate" to enter "System.EventHandler"
What I don’t understand about System.Delegate, although AddHandler accepts an argument of type "System.Delegate"? What type of "EventHandler" should be applied to the type that AddHandler can accept? Thank you for your help!
source
share