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 18 1246
You need to getType of 'e' to determine what type it is and then take it
from there.
OHM#
Christopher W. Douglas wrote: 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.
Regards - OHM# On**********@BT Internet.com
> You need to getType of 'e' to determine what type it is and then take it from there.
GetType(e) will return the same thing each time (EventArgs class) because it
is the same method that is handling the different events mentioned.
"One Handed Man [ OHM# ]" <te************ *************** @BTOpenworld.co m>
wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. You need to getType of 'e' to determine what type it is and then take it from there.
OHM#
Christopher W. Douglas wrote: 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.
Regards - OHM# On**********@BT Internet.com
"Christophe r W. Douglas" <ch************ ********@SPAM.s rs.com>
schrieb 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.
If you want to handle different events you should write different
procedures. Otherwise it's like pouring two glasses of water together and
trying to find out where each drop came from.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Thinking about it, yes your right! , what would be your answer to the OP
then?
OHM
Codemonkey wrote: You need to getType of 'e' to determine what type it is and then take it from there.
GetType(e) will return the same thing each time (EventArgs class) because it is the same method that is handling the different events mentioned.
"One Handed Man [ OHM# ]" <te************ *************** @BTOpenworld.co m> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. You need to getType of 'e' to determine what type it is and then take it from there.
OHM#
Christopher W. Douglas wrote: 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.
Regards - OHM# On**********@BT Internet.com
Regards - OHM# On**********@BT Internet.com
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
> what would be your answer to the OP
My post hasn't seemed to appear yet. Watch this space ;)
"One Handed Man [ OHM# ]" <te************ *************** @BTOpenworld.co m>
wrote in message news:ez******** ******@TK2MSFTN GP09.phx.gbl... Thinking about it, yes your right! , what would be your answer to the OP then?
OHM
Codemonkey wrote: You need to getType of 'e' to determine what type it is and then take it from there.
GetType(e) will return the same thing each time (EventArgs class) because it is the same method that is handling the different events mentioned.
"One Handed Man [ OHM# ]" <te************ *************** @BTOpenworld.co m> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. You need to getType of 'e' to determine what type it is and then take it from there.
OHM#
Christopher W. Douglas wrote: 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.
Regards - OHM# On**********@BT Internet.com
Regards - OHM# On**********@BT Internet.com
> Otherwise it's like pouring two glasses of water together and trying to find out where each drop came from.
lol. I like the metaphor. Very apt.
"Armin Zingler" <az*******@free net.de> wrote in message
news:uH******** ******@TK2MSFTN GP09.phx.gbl... "Christophe r W. Douglas" <ch************ ********@SPAM.s rs.com> schrieb 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.
If you want to handle different events you should write different procedures. Otherwise it's like pouring two glasses of water together and trying to find out where each drop came from.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Hi Armin, If you want to handle different events you should write different procedures. Otherwise it's like pouring two glasses of water together and trying to find out where each drop came from.
That is a very good answer.
Describes exactly the problem in my opinion..
(And I am serious before you don't believe it.)
Cor
Good advice CM, I really should have thought more before my posting <slaps
self on head>
Thanks !
OHM
Codemonkey wrote: what would be your answer to the OP
My post hasn't seemed to appear yet. Watch this space ;)
"One Handed Man [ OHM# ]" <te************ *************** @BTOpenworld.co m> wrote in message news:ez******** ******@TK2MSFTN GP09.phx.gbl... Thinking about it, yes your right! , what would be your answer to the OP then?
OHM
Codemonkey wrote: You need to getType of 'e' to determine what type it is and then take it from there.
GetType(e) will return the same thing each time (EventArgs class) because it is the same method that is handling the different events mentioned.
"One Handed Man [ OHM# ]" <te************ *************** @BTOpenworld.co m> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. You need to getType of 'e' to determine what type it is and then take it from there.
OHM#
Christopher W. Douglas wrote: > 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.
Regards - OHM# On**********@BT Internet.com
Regards - OHM# On**********@BT Internet.com
Regards - OHM# On**********@BT Internet.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christopher W. Douglas |
last post by:
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...
|
by: Jordan |
last post by:
I am dynamically inserting an html <input> tag as text (equivalent of an
image button) into a page via a Literal control.
Something like this gets inserted:
<input type="image" name="MyImageButton" id="MyImageButton"
src="somePic.jpg" />
I want for the code-behind to "know" when the user clicked on the image -
but I don't want to also have to dynamically specify a delegate for an event
procedure to handle this control which is really...
|
by: jaYPee |
last post by:
is there a way to know if the form is edited or not after calling
addnew? Me.BindingContext(DsStudentCourse1, "Students").AddNew()
because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event
Private Sub Students_Closing(ByVal sender As Object, ByVal e
As System.ComponentModel.CancelEventArgs)...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |