Making a custom form and inheriting it

T

Tomer

Hi,

I've made a new class that inherits from a form, added to it a public field.
Now I've added a new windows form and inherited it from the new class I've
just made.

And here the problem - the designer cann't show me the form any more.
I get an error that says that the base form cannot be loaded.

How can I fix this?

Tomer.
 
P

Peter Foot [MVP]

Thats how it is for .NETCF v1.0 I'm afraid - the designer doesn't support
inherited forms and only works with those directly inheriting
System.Windows.Forms.Form

Therefore you either have to do your layout entirely in code, or you can use
conditional compilation to create a design version of the form which
inherits from Form, which becomes tricky if your base form is referred to a
lot by your derived form since you'll need loads of

#if DESIGN
//do something is not a member of System.Windows.Forms.Form so do
nothing here for design version
#else
base.DoSomething();
#endif

Then create a configuration for your project which defines the constant
DESIGN and you can switch to this to design your form and switch back to
Debug or Release to actually run the code.

A more straightforward option is to create a new form, add the specific
controls to that form until you are happy with the layout, then change the
code to derive from your new form class and hook up the code underneath -
from which point there is no (easy) way of getting back to a designable
version.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top