Can not designer- edit form that inherits other abstract (MustInherit) form

J

Joh Smith

I have a form called Parent that I mark as abstract (MustInherit).
Then I add another form called Child that inherits Parent and implements all
Parent abstract methods. It compiles Ok, but when i try to edit Child in
Form Designer I get following error:
The designer must create an instance of type Parent' but it cannot because
the type is declared as abstract.
Funny thing is I am still able to view Parent and edit it in the designer.
There are some warnings shown, but anyway it works.,,,
Is this known limitation of Forms Designer? Are there any workarounds?

Thank You,

Joh
 
J

Joh Smith

Yes, far from perfect, but I guiess it is a workaroud...
Strange the way they implemented the designer. I have no problems with
abstract forms in other IDE, like JBuilder or Delphi....
I wonder if they had it fixed in VS 2008...
 
T

Tom Shelton

I have a form called Parent that I mark as abstract (MustInherit).
Then I add another form called Child that inherits Parent and implements all
Parent abstract methods. It compiles Ok, but when i try to edit Child in
Form Designer I get following error:
The designer must create an instance of type Parent' but it cannot because
the type is declared as abstract.
Funny thing is I am still able to view Parent and edit it in the designer.
There are some warnings shown, but anyway it works.,,,
Is this known limitation of Forms Designer? Are there any workarounds?

Thank You,

Joh

The problem is that the designer can't create an instance of the
parent form, because it is abstract. It's annoying, but the work
around that i usually use is something like:

Class BaseForm
Inherits System.Windows.Forms.Form

' method i want children to provide an implementation for
Public overidable sub MyMethod ()
' i want to force an override here, so if this gets called - blam!
throw new NotImplementedException ("You must implement this!")
End sub

End BasForm

Then inherit all my forms from baseform. It's not ideal... but, at
least it makes sure that your base implementation is not being called
and has to be overriden to do anything other then blow up :)
 

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