You must Sign In to post a response.
  • Category: .NET

    How to create custom events?

    How to create custom events?
    Please give real example of event which you have created your own?
    Please do not provide any web url.
  • #763645
    Hai Rajesh,
    When we want an event which is not available for the control under the visual studio, then we need to create such events using delegate.
    So to create the custom event, we have to create a delegate and then event corresponding to the delegate.

    public delegate void MyEventHandler(object sender, EventArgs e);

    Now we need to create the event to corresponding this :

    public event MyEventHandler MyEvent;

    So once we declared delegate and event, we can invoke the event using delegate:

    if(MyEvent !=null)
    MyEvent(this, e);

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #763783
    Thanks for reply. I know the concept. But i am looking for any sample where event should fire based on some action performed.

  • Sign In to post your comments