How can I inherit controls form forms Compact Framework

I am trying to create a multi-form app in c# for my pocket pc. I want to make one form as an template then have other forms inherit controls without having to re-create those controls in memory?
jbrashearsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

weareuProgrammerCommented:
Offcourse this cannot be done... Inhereting from a form, fine... Yes that will work fine, but for each form those controls will be recreated in memory... Remember the .NET framework handles all your pointers and refferences 4 you (unless you are writing unsafe code). Now if the control was a pointer on the child forms it would not be recreated in memory.. But you would have the following problem: when you enter text in one form into a textbox it will change the text of that textbox on all the forms. Luckely this does not happen thanks to the fact that the control is recreated.

If you mean you would like to make your application self smaller on (Pocket PC memory) then yes, go ahead and inherit from a baseform with some controls. This works fine and yes it does save some physical space (not as much as you would think though)...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
weareuProgrammerCommented:
To inherit controls: do the following:

Create a form with all the controls you would like to inherit lets call it BaseForm...

Next create the form you would like to have the inherited controls and change the following line:
public class Form1 : System.Windows.Forms.Form
{
...
}

to

public class NewForm : BaseForm
{
...
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.