确定当前事件 [英] Determine the current event

查看:75
本文介绍了确定当前事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio 2003中编写VB.NET应用程序。我编写了一个

方法来处理多个事件,例如关闭表单并更改

表格的可见状态。我有一些代码适用于所有这些

事件,但我需要在表单关闭时执行特定代码。此方法的

属性是sender(发起者)和e(事件

参数)。我知道如何让typeof(发送者)确定什么形式或

控制事件的起源,但我如何确定哪个事件是b / b
?我认为eventargs包含被触发的事件类型,

但我在MSDN中找不到任何详细说明。谢谢你的帮助。


-

Christopher W. Douglas

SRS Technologies,Inc。

christopher(dot)douglas(at)srs(dot)com

解决方案

你需要getType''e''来确定什么类型它是然后从那里拿走




OHM#


Christopher W. Douglas写道:< blockquote class =post_quotes>我正在Visual Studio 2003中编写一个VB.NET应用程序。我已经编写了一个处理多个事件的方法,比如关闭一个表单
并更改一个表单的可见状态形成。我有一些代码适用于所有这些事件,但我需要在表单关闭时执行特定的代码
。此方法的属性是sender(
originator)和e(事件参数)。我知道如何获得typeof
(发送者)来确定事件源自何种形式或控制,
但我如何确定触发了哪个事件?我认为
eventargs包含被触发的事件类型,但我无法在MSDN中找到任何详细说明这一点的内容。感谢您的帮助。




问候 - OHM#开**********@BTInternet.com


>你需要获取''e'的类型来确定它是

的类型,然后从那里获取它。


GetType(e)每次都会返回相同的内容(EventArgs类),因为它是
与处理上述不同事件的方法相同。 br />
单手男[OHM#] < te *************************** @ BTOpenworld.com>

在留言新闻中写道:%2 **************** @ TK2MSFTNGP11.phx.gbl ...您需要获取''e'的类型以确定它是什么类型然后从中获取
在那里。

OHM#

Christopher W. Douglas写道:

我在Visual Studio 2003中编写VB.NET应用程序。我有<编写了一个处理多个事件的方法,例如关闭表单
和更改表单的可见状态。我有一些代码适用于所有这些事件,但我需要在表单关闭时执行特定的代码
。此方法的属性是sender(
originator)和e(事件参数)。我知道如何获得typeof
(发送者)来确定事件源自何种形式或控制,
但我如何确定触发了哪个事件?我认为
eventargs包含被触发的事件类型,但我无法在MSDN中找到任何详细说明这一点的内容。感谢您的帮助。



问候 - OHM# On **** ******@BTInternet.com



" Christopher W. Douglas" < ch ******************** @ SPAM.srs.com>

schrieb

我写作我在Visual Studio 2003中编写了一个VB.NET应用程序。我编写了一个处理多个事件的方法,例如关闭表单和更改表单的可见状态。我有一些代码适用于所有这些事件,但我需要在表单关闭时执行特定的代码
。此方法的属性是sender(
originator)和e(事件参数)。我知道如何获得typeof
(发送者)来确定事件源自何种形式或控制,
但我如何确定触发了哪个事件?我认为
eventargs包含被触发的事件类型,但我无法在MSDN中找到任何详细说明这一点的内容。感谢您的帮助。




如果您想处理不同的活动,您应该编写不同的

程序。否则它就像是把两杯水倒在一起,然后用b $ b来试图找出每一滴水的来源。

-

Armin

http://www.plig.net/ nnq / nquote.html
http:// www .netmeister.org / news / learn2quote.html


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

解决方案

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**********@BTInternet.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.com>
wrote in message news:%2****************@TK2MSFTNGP11.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**********@BTInternet.com



"Christopher W. Douglas" <ch********************@SPAM.srs.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


这篇关于确定当前事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆