Jack wrote:
I have a 3-level class hirarchy:
1=Grandparent, 2=Parent, 3=Child
The Grandparent has a method called OnPaint which I want to override
from the Child class. I can do this, but how can I call the
Grandfather's OnPaint() method inside this newly overrided one in the
child class.
Move the important code sideways into another, Protected method.
Have the [Grandparent].OnPaint call this new method.
The Parent can do what it likes, overriding OnPaint or not.
You don't actually care.
[Child].OnPaint will override anything in [Grandparent].OnPaint or
[Parent].OnPaint, unplugging their respective implementations and
replacing it with its own.
[Child].OnPaint /can/ call your extracted method, thereby bypassing the
Parent level entirely.
I can't use: MyBase.OnPaint(..) because it expects the OnPaint(...) to
be in the Parent class immediately above.
If there's an implementation of [Parent].OnPaint, then MyBase.OnPaint
will use that. If there /isn't/, then it will "cascade" up into
[grandParent].OnPaint. Of course, you have no way of knowing which.
How can call a method from a class 2 levels further up from this child
class?
With multiple, possible overrides involved, you can't.
HTH,
Phill W.