Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 27-Dec-12 9:41am
Comments
Oleksandr Kulchytskyi at 27-Dec-12 15:45pm
   
Did you try to do anything ?? Or you expecting to receive code ?
moosa from iran at 27-Dec-12 15:53pm
   
i TRY but cannot do it;
moosa from iran at 27-Dec-12 15:53pm
   
:(
Sergey Alexandrovich Kryukov at 27-Dec-12 15:56pm
   
You are missing something very basic, hard to tell what exactly.
—SA
moosa from iran at 27-Dec-12 16:02pm
   
what you say?
Sergey Alexandrovich Kryukov at 27-Dec-12 16:09pm
   
Which part of may phrase you don't understand?
Please read my answer to see what.
—SA

1 solution

Rate this: bad
good
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.
 
—SA
  Permalink  
v3
Comments
Oleksandr Kulchytskyi at 27-Dec-12 16:30pm
   
As usual very informative and effective , my 5.
Sergey Alexandrovich Kryukov at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,805
1 OriginalGriff 6,696
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,792


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
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