By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Oct 10 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Oct 9, 7:54 am, "Joh Smith" <some...@microsoft.comwrote:
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 :)

--
Tom Shelton

Oct 10 '07 #2

P: n/a
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...

"Tom Shelton" <to*********@comcast.netwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
On Oct 9, 7:54 am, "Joh Smith" <some...@microsoft.comwrote:
>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 :)

--
Tom Shelton

Oct 11 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.