Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 613023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:57:25+00:00 2026-05-13T17:57:25+00:00

An application I’m working will have a number of forms with a lot of

  • 0

An application I’m working will have a number of forms with a lot of shared functionality. For instance, each form will have a DataGridView, many of the same buttons, much of the same UI code and so on.

I’d like to implement this by creating a base version of this common form, subclass it for all these very-similar-but-not-quite-the-same child forms, and tack on whatever additional controls and features I need for each of them.

I’ve already figured out that it helps to make the base form’s controls protected because this allows things like anchoring to work propertly. However, I have yet to find a way to automatically make the derived forms the same size as the base form.

Experience tells me there should be a simple way to do this. While it’s not much of a problem to just type in the required size by hand for every derived form right after creating it, I’d prefer to make everything as clean, simple, and automatic as possible.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:57:25+00:00Added an answer on May 13, 2026 at 5:57 pm

    I find it interesting that your derived forms do not automatically inherit the size from their base form, because this should work without you having to do anything about it.

    Suspected cause of your problem:

    I suspect your problem results from the fact that you’re using Visual Studio’s Forms Designer to edit the forms. Whenever you’ve edited a form, Windows Forms Designer generates the required code in the InitializeComponent method of your forms. Among all the generated code are assignments that set a form’s size, even if it is identical to the base form’s size. Therefore you might have to manually comment out those assignments if you want your derived form to have the same size as the base form, even when you change the base form’s size after creating the derived forms. (However, I don’t know if that might lead to further problems with the controls’ positioning & layouting.)

    // Code to be commented out in your derived form's InitializeComponent method:
    this.AutoScaleDimensions = new System.Drawing.SizeF(...);
    this.ClientSize = new System.Drawing.Size(...);
    

    Once these lines are commented out, the size as set in your base form’s InitializeComponent will be used for the derived form.

    A workaround solution:

    You can do the following so that you don’t have to manually comment-out designer-generated code every time you’ve edited a form:

    Create an form derived from your base form; let’s call it FrozenBaseForm. You will derive all other forms from this class instead of directly from the base form. Now, in this “intermediate” class, you define a new property ClientSize:

    public class FrozenBaseForm : BaseForm
    {
        new public SizeF ClientSize
        {
            get { return base.ClientSize; }
            set { }
        }
    }
    

    This will cause all assignments to ClientSize to have no effect at all and therefore preserve the size from the base form. This feels like a hack to tell the truth, but it seems to work. You might have to hide the Size property in the same way btw.

    As said, derive your forms from FrozenBaseForm instead of from BaseForm directly:

    public class DerivedForm1 : FrozenBaseForm { ... }
    public class DerivedForm2 : FrozenBaseForm { ... }
    ...
    

    Another option (last resort if all else fails):

    As a last resort, you could simply forget about the Forms Designer and just define the derived forms manually in the code editor (though I personally would not want to do this):

    public class DerivedForm : BaseForm
    {
        public DerivedForm()
        {
            // make all necessary changes to the base form:
            ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Application : I am working on one mid-large size application which will be used
Application, have a TextBlock and two Buttons, the text is displayed TextBlock by clicking
Application level events and processes in Excel are restricted to a single instance of
application = webapp.WSGIApplication( [(r'/main/profile/([a-f0-9]{40})', ProfileHandler)], debug=True) The regex in the above parameter will not
Application uses Entity Framework 4.1 with database first approach. I have in database a
Application settings in Windows Forms is a convenient way to store application-wide properties. However,
Application I am working on is desktop application based on healthcare. It is fully
Application.Run(form); Actually I tried to call this from my project. I got this exception.
My application requires an on-drive map as there will be no internet access during
My application (the bootstrap application for an installer that I'm working on needs to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.