I have two objects - one that contains some code with will fire an event, and one that contains the handler for that event. I can\'t \"AddHandler\" in the Load of the first
VB.Net creates a special private member variable in the pattern of
that you can then use to test against Nothing.
Public Event MyClick As EventHandler
Private Sub OnMyClick()
If MyClickEvent IsNot Nothing Then
RaiseEvent MyClick(Me, New EventArgs())
Else
' No event handler has been set.
MsgBox("There is no event handler. That makes me sad.")
End If
End Sub
http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx