Click here to Skip to main content
13,050,429 members (130,585 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have father form and child form. The child form inheritance from father form!
for example how add a textbox to each with samename!

Posted 27-Dec-12 9:41am
moosa il1.1K
Oleksandr Kulchytskyi 27-Dec-12 15:45pm
Did you try to do anything ?? Or you expecting to receive code ?
moosa from iran 27-Dec-12 15:53pm
i TRY but cannot do it;
moosa from iran 27-Dec-12 15:53pm
Sergey Alexandrovich Kryukov 27-Dec-12 15:56pm
You are missing something very basic, hard to tell what exactly.
moosa from iran 27-Dec-12 16:02pm
what you say?
Sergey Alexandrovich Kryukov 27-Dec-12 16:09pm
Which part of may phrase you don't understand?
Please read my answer to see what.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First of all, the parent-child relationship between form is effectively make defunct. A form can be a parent of some other control, except a form. You can work around it, but this is pretty much useless.

Instead, there is ownership relation (very important for UI consistency if you use more than one form, always use Form.Owner) and, of course, class inheritance. Inheritance has nothing to do with relationship between instances. In other words, any child controls can be added to any of the forms, under the same name or different names. If just does not matter. If the child control is inherited, this is a separate, hence an independent instance, because its parent form is also a separate instance. If can be of the base class, any form class from the inheritance hierarchy or exact same form class — it just does not matter.

I think your question is based on misunderstanding of classes vs their instances (objects). You need to learn it to understand it very clearly. This is not even the heart of OOP, this is one of the very basic prerequisites to understanding of real OOP.

Oleksandr Kulchytskyi 27-Dec-12 16:30pm
As usual very informative and effective , my 5.
Sergey Alexandrovich Kryukov 27-Dec-12 17:03pm
Thank you very much, Oleksandr.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100