Inherited Form

  • Thread starter Thread starter Jason MacKenzie
  • Start date Start date
J

Jason MacKenzie

I've created a base form that I want other forms to visually inherit from.
I've created the base project, added a form, thrown some buttons on it and
recompiled it as a class library.

I then added another project to the solution. I added and inherited form.
In the designer it looks great. However, when I run the project, the form is
not the same size, the button is not visible, and the text property of the
form is blank. Again, in the designer it looks perfect.

The whole processs seems straightforward so I'm not sure what I've missed.

Any help is appreciated,

Jason MacKenzie
 
Hi Jason,

We had a similar issue with our inherited forms recently. Out of
desperation we added an invisible label on the child form. This label
was placed in the bottom right corner of the form; this seemed to solve
our problem.

Don’t know why it works but it did, still does...
(We guessed it must be to do with anchoring and determing the size of
the form)

This might not work for you.

Hope it helps,
Philip Fourie
 
Hi Philip,

That's interesting. If I put a label on the form the derived form now shows
up as the same size as the base form. However the text property is not set
and the button from the base form is not visible.

Is this a known issue?

Jason
 
Also, looping through the derived forms controls collection only shows the
label. The button from the base form is not in the controls collection.
 
Figured it out:

I had overloaded the constructor in the base form and forgot to call

myBase.New() and
InitializeComponent()

Works like a charm now
 
Back
Top