如何处理由主项目中其他Dll中存在的表单引发的事件. [英] How to handle the event raised by the form which is present in other Dll in main project.

查看:63
本文介绍了如何处理由主项目中其他Dll中存在的表单引发的事件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个要求,我必须动态加载dll并在单击按钮时在dll中显示表单.
我可以使用反射来实现.

但是dll中的窗体具有按钮.单击它时,需要在加载dll的主项目中处理事件.

Hi
I have a requirement where i have to load the dll dynamically and display the form within the dll on a button click.
I am able to achieve this using reflection.

But the form in the dll has buttons .on click of it the events need to be handled in the main project in which dll is loaded.
please helpmehow to achieve this.

推荐答案

dll中的表单应该向外部世界公开按钮单击事件,以便他们可以订阅并处理它们方法.如果存在,则可以为按钮单击事件附加一个处理程序,并在MainForm中对其进行处理.您可以为此使用EventInfo类.
The form in the dll should be exposing the button click event to the outer world so that they can suscribe to it and handle it their way. If it is there, you can attach a handler for the button click event and handle it in the MainForm. You can make use of EventInfo class for this.


这篇关于如何处理由主项目中其他Dll中存在的表单引发的事件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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