听取from的所有指定事件 [英] Listening to all specified events of a from

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

问题描述

您好,



我正在构建一个对其有各种控件的表单,并且每个控件都有各种处理方法,例如onLoad,Click等。当某些方法被触发时,我需要编写一个日志条目,该特定控件的_something方法被触发。



但是,不是将函数调用添加到每个方法中,有没有办法创建一个能够对订阅所有相关控件和方法做出反应的监听器?



我已经读过一些关于发布者 - 订阅者的信息模型等,但它似乎更适合自定义事件。对于我的解决方案,我需要订阅内置事件,例如_Click,_Loading等。我不想在现有方法中添加额外的代码。







任何想法,这是否可能?







谢谢!

Hello,

I am building a form which has various controls on it, and each control has various methods that are handled, such as onLoad, Click etc. When certain methods are fired, I need to write a log entry that that specific control's _something method was fired.

However, instead of adding the function call into each method, is there a way of creating a listener that will be able to react to subscribe to all the relevant controls and methods?

I have read up a bit on publisher-subscriber model etc, but it seems to be more geared towards custom events. For my solution, I need to subscribe to "built-in" events, such as _Click, _Loading etc. I do not want to add additional code into the existing methods.



Any ideas, is this even possible?



Thank you!

推荐答案

阅读以下内容:

http://msdn.microsoft.com/en-us/library/ms228976.aspx [ ^ ]



< a href =http://msdn.microsoft.com/en-us/library/system.reflection.eventinfo.addeventhandler.aspx> http://msdn.microsoft.com/en-us/library/system.reflection .eventinfo.addeventhandler.aspx [ ^ ]
Read the following :
http://msdn.microsoft.com/en-us/library/ms228976.aspx[^]

http://msdn.microsoft.com/en-us/library/system.reflection.eventinfo.addeventhandler.aspx[^]


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

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