I am using AddHandler to wire a function to a control's 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 is generating a run-time exception stating:
Unable to cast object of type 'MyEventHandlerDelegate' to type 'System.EventHandler'
What am I not understanding about System.Delegate even though AddHandler takes as an argument of type "System.Delegate"? What Type does "EventHandler need to be to cast to a type that AddHandler can accept? Thanks for your help!