Using Namespace in Visual Studio 2005

P

Programatix

Hi,

Normally, I would use Namespace for all the window forms I created. With VS
2005, the code generated by the designer is hidden using partial keyword.

The question is, is there an efficient way to add any window forms created
into a namespace? Currently, I enclose the class for [filename].vb and
[filename].designer.vb inside a namespace manually.
 
P

Phill. W

The question is, is there an efficient way to add any window
forms created into a namespace?

Change the Project Template (and accompanying script) to do
what you need. It /does/ take a bit of figuring out, not least
because the script's in a weakly-typed language so it's difficult
to know jsut which Classes you're actually playing with, but if
you're doing lots of this, I'd say it's /well/ worth the mileage.

That said, I've only done it with VS'2003 to date - yet to try it
with '2005. :)

HTH,
Phill W.
 
P

Programatix

I'm sorry to say that I don't understand your solution.

In VS 2003, code created by the Designer is generated into 1 file. Let's say
I added a WinForm. To put the new WinForm into a namespace, I just view the
code and enclose the whole class with the namespace I want. But in VS 2005,
code created by the Designer is seperated into 2 files (name ?.vb and
?.designer.vb). Each contain the partial code for the class. To put the
WinForm into a namespace, I need to open the 2 files and enclose the class
in the namespace.

So, the question is, is there any easier solution?
 
J

Jay B. Harlow [MVP - Outlook]

Programatix,
| To put the
| WinForm into a namespace, I need to open the 2 files and enclose the class
| in the namespace.
|
| So, the question is, is there any easier solution?
None that I know of...

One possibility would be to move all the forms into their own project, that
has the namespace you like. However depending on the project that may be
over kill...

I would be curious how many beginner developers put individual forms in a
namespace. As I would consider it something more advanced developers would
do...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| I'm sorry to say that I don't understand your solution.
|
| In VS 2003, code created by the Designer is generated into 1 file. Let's
say
| I added a WinForm. To put the new WinForm into a namespace, I just view
the
| code and enclose the whole class with the namespace I want. But in VS
2005,
| code created by the Designer is seperated into 2 files (name ?.vb and
| ?.designer.vb). Each contain the partial code for the class. To put the
| WinForm into a namespace, I need to open the 2 files and enclose the class
| in the namespace.
|
| So, the question is, is there any easier solution?
|
| | > | >
| >> The question is, is there an efficient way to add any window
| >> forms created into a namespace?
| >
| > Change the Project Template (and accompanying script) to do
| > what you need. It /does/ take a bit of figuring out, not least
| > because the script's in a weakly-typed language so it's difficult
| > to know jsut which Classes you're actually playing with, but if
| > you're doing lots of this, I'd say it's /well/ worth the mileage.
| >
| > That said, I've only done it with VS'2003 to date - yet to try it
| > with '2005. :)
| >
| > HTH,
| > Phill W.
| >
| >
|
|
 
R

Robert Beaubien

The best reason is you can organize your forms into easier to find
namespaces for intellisense. C# users have the ability to put forms in a
folder and the form takes the namespace of the folder, but this is not true
for VB.NET. This is especially helpful for projects with lots of forms.
 

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