Live Chat Icon For mobile
Live Chat Icon

How do I intercept event subscription of a event in my base class?

Platform: WinForms| Category: Events

In C# you could intercept what gets subscribed as follows:

// In a Control derived class, for example: // Use override if the base class property was marked as virtual 
public new event EventHandler Click
        // Do not let derived classes subscribe to this event, they should instead override OnClick. 
        if (value.Target != this) base.Click += value;
    remove { base.Click -= value; }

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.