Form inheritance issues

N

Nak

Hi there,

I'm having issues inheriting from a base form of mine. The base form
contains no user controls but quite a few properties, events and
overridable methods.

When attempting to inherit from this from the designer is refusing to
show me it, and instead gives me this error message,

The designer must create and instance of type 'blabla...' but it cannot
because the type is declared as abstract.

So I guess my first question is why? It's inherited from "Form" so it's
not technically an abstract class at all, it's a derived from with parts
added. My understanding of an abstract class is one that simple contains an
object reference to the class it is abstracting...

'~~~

Public class myabstractform

Public baseform as form

End class

'~~~

Now I've had this working on previous occasions but not this time, what
could I have done to the base form to get this error? Surely it must be
down to something quite trivial. Thanks in advance for any help!

Nick.
 
C

Cor Ligthert

Nick,

This question was yesterday as well in this newsgroup.

My answer was in the kind of, "why don't you look how Microsoft does it when
they use the item "add inherrited form?"

Did you already look at that?

Cor
 
N

Nak

Hi Cor,
My answer was in the kind of, "why don't you look how Microsoft does it
when they use the item "add inherrited form?"

For some strange reason it was not showing my form in the list to choose
from!
Did you already look at that?

I just managed to fix it my removing "MustInherit" from the base forms
declaration, which kind of destroys my design, I would certainly consider
this issue a bug seeing as a "MustInherit" class isn't an "Abstract" class,
or is it?!?!

Nick.
 
H

Herfried K. Wagner [MVP]

Nak said:
I'm having issues inheriting from a base form of mine. The base form
contains no user controls but quite a few properties, events and
overridable methods.

When attempting to inherit from this from the designer is refusing to
show me it, and instead gives me this error message,

The designer must create and instance of type 'blabla...' but it cannot
because the type is declared as abstract.

So I guess my first question is why? It's inherited from "Form" so
it's not technically an abstract class at all, it's a derived from with
parts added. My understanding of an abstract class is one that simple
contains an object reference to the class it is abstracting...

An abstract class is marked with the 'MustInherit' keyword ('Public
MustInherit Class...'). The designer cannot be used with classes that have
a direct abstract base class because the designer needs to be able to
instantiate the form's base class in order to show the Windows Forms editor
for the form class. Consider this inheritance hierarchy:

...
'Class System.Windows.Forms'
'MustInherit Class Foo'
'Class Goo'

The designer will be able to show a designer for 'Form' and 'Foo', but not
for 'Goo' because its base class is abstract.
 
P

Phill. W

Nak said:
The designer must create and instance of type 'blabla...' but it cannot
because the type is declared as abstract.

The 'Studio 2003 Form Designer can't cope with Abstract forms.
My understanding of an abstract class is one that simple contains an
object reference to the class it is abstracting...

An Abstract class is one that, by definition, /cannot/ instantiated and,
sadly, that's /exactly/ what the Forms Designer wants to do before it
can instantiate your derived Form based on the Abstract one.
Now I've had this working on previous occasions but not this time,
what could I have done to the base form to get this error?

You marked it as "MustInherit".
I went down the same , Abstracting route when I started writing
inherited Forms; I couldn't find any way around this abstract base
form problem so all my base forms are concrete - or whatever the
opposite of Abstract is ;-)

HTH,
Phill W.
 
N

Nak

Hi Phil,
You marked it as "MustInherit".
I went down the same , Abstracting route when I started writing
inherited Forms; I couldn't find any way around this abstract base
form problem so all my base forms are concrete - or whatever the
opposite of Abstract is ;-)

Aah, the plain english reason for my mistake, cheers, it makes sence now
I suppose, just a shame things have to work this way. Cheers for your help!

Nick.
 
N

Nak

Hi Herfried,
An abstract class is marked with the 'MustInherit' keyword ('Public
MustInherit Class...'). The designer cannot be used with classes that
have a direct abstract base class because the designer needs to be able to
instantiate the form's base class in order to show the Windows Forms
editor for the form class. Consider this inheritance hierarchy:

I must have the completely wrong idea about abstract classes then. LOL,
oh well I understand now though. Cheers for the help!
...
'Class System.Windows.Forms'
'MustInherit Class Foo'
'Class Goo'

I get you, cheers Herfried, much appreciated!

Nick.
 

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