473,749 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5685
On Oct 9, 7:54 am, "Joh Smith" <some...@micros oft.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 NotImplementedE xception ("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*********@co mcast.netwrote in message
news:11******** **************@ 19g2000hsx.goog legroups.com...
On Oct 9, 7:54 am, "Joh Smith" <some...@micros oft.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 NotImplementedE xception ("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
1995
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 the designer blows up with an "Object Reference Not Set to an Instance of an Object". Sometimes it even (so kindly) "munches" my code in the hosting control. Unfortunately, it seldm if ever tlss "where" exactly the problem occurred, and to my...
1
1893
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 the designer blows up with an "Object Reference Not Set to an Instance of an Object". Sometimes it even (so kindly) "munches" my code in the hosting control. Unfortunately, it seldm if ever tlss "where" exactly the problem occurred, and to my...
1
2070
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 box. i know what it measn but have no clue where it is comming from. how can i debug this?
19
2985
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 provide an open TD with a DIV in it for the content of this formlet. (The DIV is for DHTML to hide and show the content) I've created a web page showing step by step the two problems I'm encountering. This problem is much easier to see than it...
1
2589
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 puts in the codebehind, as such: public class testsubclass : System.Web.UI.Page We change this to be: public class testsubclass : OurProject.Library.BaseWebPage Which is defined as:
4
2608
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 is, when I modify these tables in SQL Server (typically adding fields and what not), there doesnt seem to be an easy way to update the typed dataset. If I delete the previous table definition and drop a new one on, all of the relationships are...
3
2372
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. Shift-F7 does not work. What do I have to do in order to get a /designer/ window? Thanks Tin
2
4691
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 Visual Studio. Error 1 The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) C: \Documents and Settings\HP_Administrator\My Documents\Visual Studio
4
2646
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. - Why is this happening? - Can I disable automatic declaration and have everything be declared manually? - Any other options to fix this? Thanks in advance. Goran Djuranovic
1
1971
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 database tables by dragging tables from Server Explorer onto the O/R Designer. I dragged a table named emp onto the O/R designer. Now,if add a new column in emp table in database,and if I refresh O/R designer, the added column is not effected on...
0
8833
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.