R – Setting the namespace of a WinForms UserControl in VB.NET

namespacesvb.netwinforms

How do you define your UserControls as being in a namespace below the project namespace, ie. [RootNameSpace].[SubSectionOfProgram].Controls?

Edit due to camainc's answer: I also have a constraint that I have to have all the code in a single project.

Edit to finalise question: As I suspected it isn't possible to do what I required so camainc's answer is the nearest solution.

Best Solution

I'm not sure if this is what you are asking, but this is how we do it.

We namespace all of our projects in a consistent manner, user controls are no different. We also namespace using the project settings window, although you could do it through a combination of the project window and in code.

Each solution gets a namespace like this:

[CompanyName].[SolutionName].[ProjectName]

So, our user controls are normally in a project called "Controls," which would have a namespace of:

OurCompany.ThisSolution.Controls

If we have controls that might span several different solutions, we just namespace it like so:

OurCompany.Common.Controls

Then, in our code we will import the library, or add the project to the solution.

Imports OurCompany
Imports OurCompany.Common
Imports OurCompany.Common.Controls

We also name the folders where the projects live the same as the namespace, down to but not including the company name (all solutions are assumed to be in the company namespace):

\Projects
\Projects\MySolution
\Projects\MySolution\Controls

-- or --

\Projects\
\Projects\Common
\Projects\Common\Assemblies
\Projects\Common\Controls

etc.

Hope that helps...