Hardy,
Add a method called OnClick to class A. In the event handler, call this
method. In class B just override the method. Make sure class B calls
base.OnClick
What I need is, once the event is fired in ClassA, how can I make
inherited classes (e.g ClassB) to know base class fires an event?
Although Joe provided a good answer to the question, "How does one invoke
the event handler of a superclass from one of its subclasses?", I believe
your question was, "How does one invoke the event handler of all subclasses
from one of its superclasses?" This is an interesting question and has many
complications. However, the psuedo code might look like this:
1. If the interesting event handler is triggered on an instance of ClassA
continue to step 2; otherwise exit
2. Use reflection to traverse the hierarchy of ClassA to find all classes
that inherit from ClassA
3. Find all instances of all of the classes found in step 2
4. Invoke the interesting event handler for each of the instances found in
step 3.
I thought I would respond with this much information to see if I understand
your question. We can discuss ways to accomplish each of these steps in
follow-up responses, if necessary.
Regards,
Randy