简体   繁体   English

如何从ActiveX控件引发事件

[英]How to Raise Event from ActiveX control

I am new in c#. 我是C#的新手。 I am working on image processing. 我正在图像处理。 I am creating a UserControl (ActiveX) which is adding just a panel on it. 我正在创建一个仅在其上添加面板的UserControl(ActiveX)。

When i use this user control in my another application then how i get the different events. 当我在另一个应用程序中使用此用户控件时,我如何获得不同的事件。

Suppose i want all mouseEvents occurred in my userContol then how i get in my application that mouse event occurred. 假设我希望所有mouseEvents都发生在userContol中,那么我如何在我的应用程序中得知发生了鼠标事件。

How User control raise a event and how i get in my application. 用户控件如何引发事件以及如何进入应用程序。 Because i need to add some functionality on that events too from my application. 因为我也需要从我的应用程序中为该事件添加一些功能。

Now i got it. 现在我懂了。 I have to define some delegates on my user control. 我必须在用户控件上定义一些委托。 And i have to attach event from calling side or where i am using that control. 而且我必须从呼叫方或在使用该控件的地方附加事件。 Thanks paw. 谢谢爪子。

If I understand your question correctly, then you can reraise the events and hook them up in your other application. 如果我正确理解了您的问题,则可以重新引发这些事件,并将其连接到其他应用程序中。

public EventHandler<EventArgs> Button1Clicked;
private void button1_Click(object sender, EventArgs e)
{
    if (this.Button1Clicked != null)
    {
        this.Button1Clicked(sender, e);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM