如何以编程方式在Ocx控件中创建新事件 [英] How to Create an New event in Ocx Control programatically

查看:60
本文介绍了如何以编程方式在Ocx控件中创建新事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用windows form c#application。我需要以编程方式使用ActiveX控件创建一个新事件c#。有没有办法用c#为控件创建一个新事件。如果有,请给我一些解决方案。













谢谢

Sathish.S

Hi,

I am working in windows form c# application.I have a requirement that i need to create a new event for ActiveX control programatically using c#.Is there any way to create a new event for a control using c#.If so Please provide me some solution.






Thanks
Sathish.S

推荐答案

通常以编程方式创建意味着您的代码在运行时创建了某些内容,否则创建事件将意味着使用添加的事件成员创建新的(或更新的)代码 。事件是某些控件类型(或任何其他类型)的成员,您不能以编程方式添加它。把它忘了吧。相反,开始学习一些编程并尝试理解代码生命周期的不同阶段;什么编译做什么,加载过程中发生了什么,JIT编译如何工作,在运行时发生了什么?& hllip [;



虽然很可能:使用 System.Reflection.Emit 您可以在运行时创建一个全新的程序集,包含任何可思考的类型和这些类型的成员。但它与ActiveX组件无关。在.NET中,ActiveX仅对重用某些遗留代码有用。如果需要升级遗留代码,那么在没有任何COM或ActiveX的情况下创建纯.NET组件会好得多。



整个问题根本没有意义。



-SA
Usually "create… programmatically" means that your code creates something during runtime, otherwise "create an event" would mean "create a new (or updated) code with added event member". Event is a member of some control type (or any other type), you cannot add it "programmatically". Just forget it. Instead, start learning some programming and try to understand what different phases of code lifetime to; what compilation does, what happens during loading, how JIT compilation works, what else happens during runtime&hllip[;

A very remote possibility though: using System.Reflection.Emit you can create a whole new assembly during runtime, with any thinkable types and members of those types. But it has nothing to do with ActiveX components. In .NET, ActiveX can be useful only for reusing of some legacy code. If there is some need for upgrading legacy code, creation of the pure .NET components without any COM or ActiveX would be much better.

The whole question simply makes no sense.

—SA


这篇关于如何以编程方式在Ocx控件中创建新事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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