How Do I Inherit A Form?

Joined
Aug 23, 2006
Messages
7
Location
Northwestern North Carolina
Programming Experience
1-3
Hi all,

I'm having trouble creating a form that inherits properties and methods from a base form. My project name is MultiForms and my first form is baseForm. It's inherit statement reads: Inherits System.Windows.Forms.Form.

I then add a new form, call it mainForm, and change its inherit statement to: Inherits MultiForms.baseForm.

The new form won't display in design mode! I get an error message saying that this form's design can't be shown because none of the classes within it can be designed.

What am I doing wrong? Any help would be much appreciated!

SFT
 
StrayFlyingToaster, i hope you got yuor problemn sorted, but i'm just a bit curious as to what you are doing in your base form that would cause this kind of error. For all intents and purposes the way you tried it should have worked. I'm just a bit curious thats all.
 
With respect to the error message you received, I believe that that is what happens when you try to inherit a form without building the project first. If you select Inherited Form rather than Windows Form then that will invoke the Inheritance Picker dialogue, which will tell you if the current project requires building before a form can be inherited.
 
if you're building the inherited form in the same project then add a new form to the designer and change the Inherited line from "Windows.Forms.Form" to "YourProject.YourForm"

with "YourProject" being the name of the project that the inherited form resides and "YourForm" being the actual form in which to inherit from
 
Reason for my error message

The reason I got the error message was that I had my base form entered as the startup object under the project properties menu.

BTW, that is also why adding an inherited form didn't work either. I suppose I should've pointed out I tried that as well...:rolleyes:


thanks all,
Toast'r
 
The reason I got the error message was that I had my base form entered as the startup object under the project properties menu.

BTW, that is also why adding an inherited form didn't work either. I suppose I should've pointed out I tried that as well...:rolleyes:


thanks all,
Toast'r
I'm sorry but that's not true. There's absolutely no reason that your startup form cannot be inherited. I just tried it in VS.NET 2003 and it worked fine. In my testing the only way I can come up with the error message that you got, bot in 2003 and 2005, is to try to inherit a form before building the project for the first time. There may be other ways that i'm not aware of but they certainly have nothing to do with your startup form.
 
You’re right.

I tried it again and found that in order to add an inherited form, the form it was to be based upon had to be built – and the startup object can be used to inherit from.

So the reason I was having difficulty was because I hadn’t built the original form before trying to inherit another from it. Just as you said.


Thank you very much for bringing this to light. I’m new to this and appreciate all the help I can get!

SFT
 
Back
Top