How can I inherit controls form forms Compact Framework

Posted on 2004-11-18
Last Modified: 2010-05-18
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?
Question by:jbrashears
    LVL 2

    Accepted Solution

    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)...
    LVL 2

    Expert Comment

    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


    public class NewForm : BaseForm

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now