473,395 Members | 2,437 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,395 software developers and data experts.

Problems with an inherited Form

Uty
(Originally posted this in VC++ section .. whoops

I'm working on a series of projects which have a few things in common, which has been abstracted into an object we'll call ParentForm. I started a new (actually, the first) project. It's "main" form is called ChildForm, and it inherets from ParentForm. I added ParentForm.cs to the project via the Solution Explorer. If I right click on ParentForm.cs and choose "View Designer" I can see the designer just fine. The form appears exactly as it should. However, if I do the same for ChildForm.cs, I get this error: "An exception occured while trying to create an instance of <namespace>.ChildForm. The exception was "Object reference not set to an instance of an object." Oddly enough though, I can compile and run ChildForm fine. I just can't design it. Any suggestions

//ParentForm.c
namespace myNamespac

public class ParentForm : System.Windows.Forms.For

//Member variables such as Menu, MenuItems, TextBox, etc

public ParentForm(

InitializeComponent()
...
..

// No Mai

//ChildForm.c

namespace myNamespac

public class ChildForm : ParentFor

//No new members yet as I'm just trying to get the design set up

public ChildForm() : base(

InitializeComponent()
..
..

static void Main(

Application.Run( new ChildForm() )


Nov 16 '05 #1
3 1925
Where you have the ctor
public ChildForm() : base()
try getting rid of the : base()
I dont think it is needed as the base ctor will execute anyway. No?
I have a couple of inherited forms which follow this rule and they all work
fine.
Cheers
JB
"Uty" <an*******@discussions.microsoft.com> wrote in message
news:24**********************************@microsof t.com...
(Originally posted this in VC++ section .. whoops)

I'm working on a series of projects which have a few things in common, which has been abstracted into an object we'll call ParentForm. I started a
new (actually, the first) project. It's "main" form is called ChildForm,
and it inherets from ParentForm. I added ParentForm.cs to the project via
the Solution Explorer. If I right click on ParentForm.cs and choose "View
Designer" I can see the designer just fine. The form appears exactly as it
should. However, if I do the same for ChildForm.cs, I get this error: "An
exception occured while trying to create an instance of
<namespace>.ChildForm. The exception was "Object reference not set to an
instance of an object." Oddly enough though, I can compile and run
ChildForm fine. I just can't design it. Any suggestions?
//ParentForm.cs
namespace myNamespace
{
public class ParentForm : System.Windows.Forms.Form
{
//Member variables such as Menu, MenuItems, TextBox, etc.

public ParentForm()
{
InitializeComponent();
....
}

...

// No Main
}
}
//ChildForm.cs

namespace myNamespace
{
public class ChildForm : ParentForm
{
//No new members yet as I'm just trying to get the design set up.

public ChildForm() : base()
{
InitializeComponent();
...
}

...

static void Main()
{
Application.Run( new ChildForm() );
}
}
}

Nov 16 '05 #2
Uty
Thanks for your reply. I have it a try but unfortunatly I still get the same exception when trying to view ChildForm in the IDE's designer.
Nov 16 '05 #3
Uty
So, I decided to start over from scratch, sort of, by slowly adding my original code to a new project. ParentForm had a series of event handlers which get initialized in a function I called InitializeEventHandlers. I made it a public function. If it is called in ParentForm's constructor, I get the error. If it is called in ChildForm's constructor I do not. So, I found a way around it ... but I would call this a fairly annoying design flaw. Good thing I've got a client paying for this time, right? >:(
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gian U. Uy | last post by:
Hi, I have a colleague that has problems with Internationalization issues, has someone encountered this problem? --------------------- Inherited form shrinks when base form is created under...
0
by: Frnak McKenney | last post by:
I'm running into problems with VisualStudio.NET2003 and Windows Forms inheritance. It _feels_ like a bug, but it could just as well be a misunderstanding on my part regarding how the VS Designer...
2
by: Giovanni Bassi | last post by:
Hello All, I have encountered a problem. I am using visual inheritance and my base form adds an event handler on Form Load using the AddHandler Keyword. The problem is that if the Event...
13
by: Lorne Smith | last post by:
Hi, First, sorry for the crosspost, but it seemed appropriate... :) I've come accross what I consider to be a bug, but I don't know if it's already known or not. (VS .Net 2003 Pro - VB.Net) ...
4
by: JC Voon | last post by:
Hi: My base form has a button, when click it will call MessageBox.Show( "Base form" ). I inherite a child form from the base and assign a button click event to the same button which will call...
2
by: Peter | last post by:
I have a base form from which many forms inherit. The base form is in one project, and the inherits form is in another project. Both projects are under the same solution space. Both forms...
2
by: Zull | last post by:
I've got a base form wich is a parent form for few others. On this base form I have dataGridView control, which has Modifiers property set on 'Protected Internal'. Unfortuantely, it does not...
4
by: asad.naeem | last post by:
hi to all this is the problem about inheritence. I have designed a form with some essential controls which are required for every form which will inherited from it. for example i have Button1 on...
0
by: SM | last post by:
Hi, #1 I did some changes in my inherited form (change some properties of my components), now I want to rollback all changes made in inherited form and return to the same state as the...
0
by: Paul W | last post by:
Hello everyone, My problem is with an inherited Form. The base Form has a few controls on it that are anchored such that they move as the Form is resized. While in the designer, the inherited...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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...
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
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...
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.