Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2006

Tip: Looking for answers? Try searching our database.

Why can't you inherit System.Windows.Forms.Form?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob Nicholson - 04 Feb 2006 12:28 GMT
The designer doesn't seem to like it but the question is why was it designed
like this?

Cheers, Rob.

PS. And can you do it in VS 2005?
Herfried K. Wagner [MVP] - 04 Feb 2006 13:34 GMT
"Rob Nicholson" <rob.nicholson@nospam_unforgettable.com> schrieb:
> The designer doesn't seem to like it but the question is why was it
> designed like this?

You actually can make a form inherit from 'System.Windows.Forms.Form',
that's what is actually done when adding a new form to the project.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Rob Nicholson - 05 Feb 2006 11:54 GMT
> You actually can make a form inherit from 'System.Windows.Forms.Form',
> that's what is actually done when adding a new form to the project.

But you can't put an intermediate inherited class in the way though. You can
on ASP.NET - we have our own MyApp.Page class which is ineffect the equiv.
of the form.

Cheers, Rob.
Herfried K. Wagner [MVP] - 05 Feb 2006 12:09 GMT
"Rob Nicholson" <rob.nicholson@nospam_unforgettable.com> schrieb:
>> You actually can make a form inherit from 'System.Windows.Forms.Form',
>> that's what is actually done when adding a new form to the project.
>
> But you can't put an intermediate inherited class in the way though. You
> can on ASP.NET - we have our own MyApp.Page class which is ineffect the
> equiv. of the form.

You can create a class which inherits from 'Form' and a second class which
inherits from your custom form class ("Project" -> "Add inherited form...").

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Rob Nicholson - 10 Feb 2006 01:19 GMT
> You can create a class which inherits from 'Form' and a second class which
> inherits from your custom form class ("Project" -> "Add inherited
> form...").

Ahh ha - that was the missing link. I was simply trying to create a base
class that was normal class, not a form which is then inherited. Works a
treat.

Thanks, Rob.
Bob Powell [MVP] - 05 Feb 2006 13:26 GMT
Take a look at the ideas of Visual Inheritance.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

>> You actually can make a form inherit from 'System.Windows.Forms.Form',
>> that's what is actually done when adding a new form to the project.
[quoted text clipped - 4 lines]
>
> Cheers, Rob.
Bruce Wood - 06 Feb 2006 21:06 GMT
> > You actually can make a form inherit from 'System.Windows.Forms.Form',
> > that's what is actually done when adding a new form to the project.
[quoted text clipped - 4 lines]
>
> Cheers, Rob.

Is the "intermediate inherited class" abstract, by any chance?
Peter Oliphant - 07 Feb 2006 18:11 GMT
Not sure what you mean. This works, I do it all the time:

ref class MyForm : public Form
{
       MyForm() : Form() {}
} ;

even:

ref class MyDerivedForm : public MyForm
{
MyDerivedForm() : MyForm() {}
} ;

Note that 'Form' is 'System.Windows.Forms.Form', but I use 'using' to avoid
excessive typing... : )

[==P==]

> "Rob Nicholson" <rob.nicholson@nospam_unforgettable.com> schrieb:
>> The designer doesn't seem to like it but the question is why was it
>> designed like this?
>
> You actually can make a form inherit from 'System.Windows.Forms.Form',
> that's what is actually done when adding a new form to the project.
Patrice - 06 Feb 2006 13:01 GMT
What is the behavior you see ? This is what the designer always do when you
create a form ! Should work.

Signature

Patrice

> The designer doesn't seem to like it but the question is why was it designed
> like this?
>
> Cheers, Rob.
>
> PS. And can you do it in VS 2005?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.