Christopher,
You are correct that the "Sender" argument identifies the form or control
that raised the event. The "e" or EventArgs argument is simply an object
that contains additional arguments specific to that event. As many different
events share the same type of parameters (called its "Signature" ) you cannot
identifty the actual event being rased from this parameter.
You would be better off having separate event handler methods for each event
and moving the common code into a separate procedure which is called from
each event handler.
For example:
---------------------------------
Private Sub Form_Closing(By Val sender As Object, ByVal e As CancelEventArgs )
Handles MyBase.Closing
DoCommonStuff()
' Code for closing goes here
End Sub
Private Sub Form_VisibleCha nged(ByVal sender As Object, ByVal e As
EventArgs) Handles MyBase.VisibleC hanged
DoCommonStuff()
' Code for visible changed goes here
End Sub
Private Sub DoCommonStuff()
' Do stuff common to both events here
End Sub
--------------------------------------------
Hope this helps,
Trev.
"Christophe r W. Douglas" <ch************ ********@SPAM.s rs.com> wrote in
message news:%2******** **********@TK2M SFTNGP11.phx.gb l...
I am writing a VB.NET application in Visual Studio 2003. I have written a
method that handles several events, such as closing a form and changing
the visible status of a form. I have some code that applies to all these
events, but I need to have specific code execute when the form closes. The
properties for this method are sender (the originator) and e (event
arguments). I know how to get typeof (sender) to determine what form or
control the event originated from, but how do I determine which event was
fired? I would think that eventargs contains the type of event that
fired, but I could not find anything in MSDN detailing this. Thanks for your
help.
--
Christopher W. Douglas
SRS Technologies, Inc.
christopher (dot) douglas (at) srs (dot) com