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

  • Thread starter Thread starter Rob Nicholson
  • Start date Start date
R

Rob Nicholson

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?
 
Rob Nicholson said:
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.
 
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.
 
Rob Nicholson said:
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...").
 
What is the behavior you see ? This is what the designer always do when you
create a form ! Should work.
 
Rob said:
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.

Is the "intermediate inherited class" abstract, by any chance?
 
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==]
 
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.
 
Back
Top