Re: Inheritance in forms which inherit template forms by howlinghound
howlinghound
Mon Jan 03 10:03:03 CST 2005
Child classes are down! I always goof up this one!
So even though a control is placed on a child class, it will be added to the
Controls collection higher up in the inheritance chain. The child class
doesn't have it's own Controls collection, it uses the inherited one.
Unlike a control, if I create some other object local to a child class,
which is not stored in a "collection" in a higher base class, this local
object will not be visible to base classes.
Got it! Thanks for your help.
Michael
"joeycalisay" wrote:
> > why should
> > a base class have the controls of a class above it (the derived form), in
> its
> > controls collection.
>
> Technically, child classes are DOWN not up/above the hierarchy. Anyway, the
> CONTROLS (Control Collection) property of the form is declared as public and
> is therefore inherited down the hierarchy tree. Custom controls added in
> your child forms are also added to this inherited property and if you are
> debugging after the child class was instantiated and the Controls in it are
> added (usually in InitializeComponent method), you will normally see them.
> Your base form, child form all share the same Controls collection which is
> defined in System.Windows.Forms.Control class which is a base class of
> System.Windows.Forms.Form
>
>
>