Inherited Forms in VB.NET class code does not show 'inherits from...'

J

jandhondt

In VS2005 with VB.NET when a form or usercontrol is inherited: it is
terribly annoying that the code view shows as Public Class statement
without the inherits statement.

You have to go to the myform.designer.vb code to show this inheritance.

Also it is unclear to me where to put an overloaded New(...)
definition: in the partial class where you'd type all your other code,
or in the myform.designer.vb code ?

Jan D'Hondt
Database development in .NET
DotNetNuke development
 
P

Patrice

The designer file is there to isolate designer generated code from your own
code. Keep your own code inside the myform.vb class...

For the first point, I don't really have anyway to solve this. Perhaps using
a naming convention or a specific folder for Forms ? You could add this as a
comment (or perhaps as a statement but I don't know how the compiler will
react)...
 
R

Robinson

jandhondt said:
In VS2005 with VB.NET when a form or usercontrol is inherited: it is
terribly annoying that the code view shows as Public Class statement
without the inherits statement.

You have to go to the myform.designer.vb code to show this inheritance.

I have to agree to with this. I have solved it to an extent as Patrice says
by having a folder structure that reflects inheritance in my solution.
 
J

jandhondt

Tnx for the replies.

One big reason for me to switch from the old VB6 to VB.NET was the fact
that all the code for a form was in 1 file and it was all code, which
gave us a lot more control over all the controls in a form compared to
the hidden and unreachable code behind VB6 forms. als great for
applying inheritance and so forth.
Then came VB.2005 and they started to give up the principle of having
everything in one file and moved to more hidden files again. There's a
an american saying : "If it ain't broken, don't fix it". If only they
could appreciate this a bit more at Microsoft.
BTW they did add a lot of good things too, but if only they could keep
their hands off of things that worked.

Robinson schreef:
 
P

Patrice

I gave a try at the other option and it works. You are allowed to duplicate
the inherits statement used in myfile.designer.vb in the myfile.vb file. The
compiler will report an error only if you you don't inherit from the same
class in those two files...
 
R

Robinson

jandhondt said:
Tnx for the replies.

One big reason for me to switch from the old VB6 to VB.NET was the fact
that all the code for a form was in 1 file and it was all code, which
gave us a lot more control over all the controls in a form compared to
the hidden and unreachable code behind VB6 forms. als great for
applying inheritance and so forth.
Then came VB.2005 and they started to give up the principle of having
everything in one file and moved to more hidden files again. There's a
an american saying : "If it ain't broken, don't fix it". If only they
could appreciate this a bit more at Microsoft.
BTW they did add a lot of good things too, but if only they could keep
their hands off of things that worked.

Ah well to be honest, I mostly prefer not having the code cluttering up my
main source file, especially as it's designer generated. There are certain
important things I would like to see in the user source file though -
inheritance is one of them and also the constructor. However the latter
appears as soon as you write Public Sub New and press enter so it's no
biggie. Overall I think 2005 (and .NET 2.0) are a huge improvement over
what came before.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top