Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hello
I have father form and child form. The child form inheritance from father form!
for example how add a textbox to each with samename!


thank.
Posted
Comments
Oleksandr Kulchytskyi 27-Dec-12 15:45pm    
Did you try to do anything ?? Or you expecting to receive code ?
moosa il 27-Dec-12 15:53pm    
i TRY but cannot do it;
moosa il 27-Dec-12 15:53pm    
:(
Sergey Alexandrovich Kryukov 27-Dec-12 15:56pm    
You are missing something very basic, hard to tell what exactly.
—SA
moosa il 27-Dec-12 16:02pm    
what you say?

1 solution

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.

—SA
 
Share this answer
 
v3
Comments
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.
—SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900