Hello:
I have a project that I need to have many forms. The forms will have many properties and objects the same.
Instead of me adding a new form and them changing all the properties and adding all the objects that I need. Is there a way I can just bring in a form with the changes already made? Is that Inherited for do what I need? Seems that the Inherited form locks all the objects and I cant change the names or text.
Loading
NainilPosted Mar 8, 2010, 1:57 PM
I'm sorry, didn't read your description in deatil. In that case, what you would want to do is to make all the controls Protected instead of Private. You can change it on the designer by changing the Modifiers property of a control to Protected. Build your solution, and then starting using the parent form. Now you should be able to unlock the controls, modify them, or add controls to the parent form controls. Let me know it that helps.
GustavoPosted Mar 8, 2010, 3:48 PM
I have resolved this issue. Thanks anyways.
theLizardPosted Mar 8, 2010, 3:45 PM
Also send an example of the other controls you want to add to a new copy of the sample form.
NainilPosted Mar 8, 2010, 2:15 PM
Nothing wrong in making them Public. However if it is Public, then if there are any Form instances created in code, you can easily access all the controls since they are public and easily accessible. This is generally not a good technique. The controls should always remain private unless you have a very strong reason otherwise.
Making them Protected means that an inheriting class will be able to have access to those protected controls of the parent class. However when an instance of the child class is created, you cannot access those controls in the parent class. Those controls are only accessed while creating the class (writting the code for class), not while instantiating the instance of the class. Kindly let me know if you need further explaination.
GustavoPosted Mar 8, 2010, 2:09 PM
THANK YOU.... Thats it.
Question: Instead of Protected, why can I not make it Public?
GustavoPosted Mar 8, 2010, 1:44 PM
I have the ParentFom with the foillowing:
1) toolStrip
2) groupBox
3) tabControl
4) statusStrip
5) Form as a specific size.
I want to later change the groupBox and tabControl for the specific form use.
GustavoPosted Mar 8, 2010, 1:41 PM
Yes, that is what I dod. However, After I bring in the form, I would like to change some of the objects. They are locked and can not change them.
The reason I want to change them is:
1) So I can change their name.
2) Add additional objects in the like groupBox.
3) Change tabPages...
Is there a way to unlock them?
NainilPosted Mar 8, 2010, 1:32 PM
You have 2 options to do this. They are listed as following:
By performing the above steps, all the new forms generated in your project should have the same user interface and objects. Hope this hleps.