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

  • Home
  • SEARCH
  • 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 668277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:01:20+00:00 2026-05-14T00:01:20+00:00

I engaged a problem with inherited Controls in Windows Forms and need some advice

  • 0

I engaged a problem with inherited Controls in Windows Forms and need some advice on it.

I do use a base class for items in a List (selfmade GUI list made of a panel) and some inherited controls that are for each type of data that could be added to the list.

There was no problem with it, but I now found out, that it would be right, to make the base-control an abstract class, since it has methods, that need to be implemented in all inherited controls, called from the code inside the base-control, but must not and can not be implemented in the base class.

When I mark the base-control as abstract, the Visual Studio 2008 Designer refuses to load the window.

Is there a way to get the Designer work with the base-control made abstract?

  • 1 1 Answer
  • 0 Views
  • 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-14T00:01:20+00:00Added an answer on May 14, 2026 at 12:01 am

    I KNEW there had to be a way to do this (and I found a way to do this cleanly). Sheng’s solution is exactly what I came up with as a temporary workaround but after a friend pointed out that the Form class eventually inherited from an abstract class, we SHOULD be able to get this done. If they can do it, we can do it.

    We went from this code to the problem

    Form1 : Form
    

    Problem

    public class Form1 : BaseForm
    ...
    public abstract class BaseForm : Form
    

    This is where the initial question came into play. As said before, a friend pointed out that System.Windows.Forms.Form implements a base class that is abstract. We were able to find…

    Proof of a better solution

    • Inheritance Hierarchy:

      • System.Object
        • System.MarshalByRefObject (public **abstract** class MarshalByRefObject)
          • System.ComponentModel.Component
            • System.Windows.Forms.Control
              • System.Windows.Forms.ScrollableControl
                • System.Windows.Forms.ContainerControl
                  • System.Windows.Forms.Form

    From this, we knew that it was possible for the designer to show a class that implemented a base abstract class, it just couldn’t show a designer class that immediately implemented a base abstract class. There had to be at max 5 inbetween, but we tested 1 layer of abstraction and initially came up with this solution.

    Initial Solution

    public class Form1 : MiddleClass
    ...
    public class MiddleClass : BaseForm
    ... 
    public abstract class BaseForm : Form
    ... 
    

    This actually works and the designer renders it fine, problem solved…. except you have an extra level of inheritance in your production application that was only necessary because of an inadequacy in the winforms designer!

    This isn’t a 100% surefire solution but its pretty good. Basically you use #if DEBUG to come up with the refined solution.

    Refined Solution

    Form1.cs

    public class Form1
    #if DEBUG
        : MiddleClass
    #else 
        : BaseForm
    #endif
    ...
    

    MiddleClass.cs

    public class MiddleClass : BaseForm
    ... 
    

    BaseForm.cs

    public abstract class BaseForm : Form
    ... 
    

    What this does is only use the solution outlined in "initial solution", if it is in debug mode. The idea is that you will never release production mode via a debug build and that you will always design in debug mode.

    The designer will always run against the code built in the current mode, so you cannot use the designer in release mode. However, as long as you design in debug mode and release the code built in release mode, you are good to go.

    The only surefire solution would be if you can test for design mode via a preprocessor directive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.