473,412 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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

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
2 5668
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
I have some complex (fairly) user controls that I have created. Some of those user controls host other user controls. When I host one of these on a WinForm, I sometimes run into problems where...
1
by: Jim | last post by:
I have some complex (fairly) user controls that I have created. Some of those user controls host other user controls. When I host one of these on a WinForm, I sometimes run into problems where...
1
by: Raj Chudasama | last post by:
i have an app that uses a lot of bitmaps, associated with various classes etc on the gui. Everytime i open then designer i am getting a "object reference not set to an instance of an object" msg...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
1
by: Chuck Haeberle | last post by:
We have need to share functionality across all of our application web pages, so we decided to subclass from System.Web.UI.Page. When we create a new aspx, the Visual Studio designer automatically...
4
by: Dave Taylor | last post by:
I've been using the dataset designer in Visual Studio to create typed datasets for my application by dragging over tables from the Server Explorer and dropping them into the designer. The problem...
3
by: Tin Gherdanarra | last post by:
A colleague gave me a project where there was a /designer/ window for database connectivity (drag&drop from the toolbox), but I can't find out how to get a /designer/ window in my own project....
2
by: dejavue82 | last post by:
Does anybody know how to resolve the following errors? They were caused by the designer.cs file that was auto-generated by the LINQ to SQL designer. I am using the March 2007 Orcas CTP version of...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
1
by: silpa | last post by:
Hi, The Visual Studio Linq for SQL designer is not supporting refreshing tables and column information from the database. For example,I have created LINQ to SQL classes that are mapped to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.