473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Move Form to Namespace (VB 2005)

Hi all,

I have a Form called "Main":

Public Class Main

Private Sub Button1_Click( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click

End Sub

End Class
Now I want to put the form into a namespace called "Forms". If I put the
lines "Namespace Forms" and "end namespace" before and after the code above,
I get an error at the "Handles" clause. Reason: The "Partial Class" in
Main.Designer.vb is still in the old Namespace. Consequently the class in
Main.vb is a different class not having any buttons anymore, therefore the
error.

Now I could manually also put the whole "Partial Class" into the "Forms"
namespace, but as the file is "designer generated" I can not touch it (or
take the risk that my lines will be overwritten).

So, how do I move a Form into a namespace in VB 2005? This was no problem in
VB 2003 because it was all one file.
Armin

Feb 11 '07 #1
7 2940
On 2007-02-11, Armin Zingler <az*******@freenet.dewrote:
Hi all,

I have a Form called "Main":

Public Class Main

Private Sub Button1_Click( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click

End Sub

End Class
Now I want to put the form into a namespace called "Forms". If I put the
lines "Namespace Forms" and "end namespace" before and after the code above,
I get an error at the "Handles" clause. Reason: The "Partial Class" in
Main.Designer.vb is still in the old Namespace. Consequently the class in
Main.vb is a different class not having any buttons anymore, therefore the
error.

Now I could manually also put the whole "Partial Class" into the "Forms"
namespace, but as the file is "designer generated" I can not touch it (or
take the risk that my lines will be overwritten).

So, how do I move a Form into a namespace in VB 2005? This was no problem in
VB 2003 because it was all one file.
Armin
Just change it and make your default namespace the new namespace. You should
have a problem with it... At least, I haven't in c# :)

--
Tom Shelton
Feb 11 '07 #2
"Tom Shelton" <to*********@comcastXXXXXXX.netschrieb
On 2007-02-11, Armin Zingler <az*******@freenet.dewrote:
Hi all,

I have a Form called "Main":

Public Class Main

Private Sub Button1_Click( _
ByVal sender As System.Object, ByVal e As
System.EventArgs) _ Handles Button1.Click

End Sub

End Class
Now I want to put the form into a namespace called "Forms". If I
put the lines "Namespace Forms" and "end namespace" before and
after the code above, I get an error at the "Handles" clause.
Reason: The "Partial Class" in Main.Designer.vb is still in the
old Namespace. Consequently the class in Main.vb is a different
class not having any buttons anymore, therefore the error.

Now I could manually also put the whole "Partial Class" into the
"Forms" namespace, but as the file is "designer generated" I can
not touch it (or take the risk that my lines will be overwritten).

So, how do I move a Form into a namespace in VB 2005? This was no
problem in VB 2003 because it was all one file.
Armin

Just change it and make your default namespace the new namespace.
You should have a problem with it... At least, I haven't in c# :)
Uhm, sorry, but I don't understand. What should I change? The designer
generated file? Why should I have a problem with it? I don't want to change
the default namespace (you mean the root namespace of the project?), I only
want to put the Form in the Namespace.
Armin

Feb 11 '07 #3
In article <Oy**************@TK2MSFTNGP05.phx.gbl>, az*******@freenet.de
says...
Now I want to put the form into a namespace called "Forms". If I put the
lines "Namespace Forms" and "end namespace" before and after the code above,
I get an error at the "Handles" clause. Reason: The "Partial Class" in
Main.Designer.vb is still in the old Namespace. Consequently the class in
Main.vb is a different class not having any buttons anymore, therefore the
error.

Now I could manually also put the whole "Partial Class" into the "Forms"
namespace, but as the file is "designer generated" I can not touch it (or
take the risk that my lines will be overwritten).
I've done this before (in C#) and never had a problem with VS.NET
messing up my namespace declaration in the Main.Designer.cs file after
editing the form.

--
Patrick Steele
http://weblogs.asp.net/psteele
Feb 12 '07 #4
You need to right click your solution and select view hidden files. Now you
can see and edit the designer files. The issue you are running up against
is that the VB IDE creates "default" namespaces.

Mike Ober.

"Patrick Steele" <pa*****@mvps.orgwrote in message
news:MP************************@msnews.microsoft.c om...
In article <Oy**************@TK2MSFTNGP05.phx.gbl>, az*******@freenet.de
says...
>Now I want to put the form into a namespace called "Forms". If I put the
lines "Namespace Forms" and "end namespace" before and after the code
above,
I get an error at the "Handles" clause. Reason: The "Partial Class" in
Main.Designer.vb is still in the old Namespace. Consequently the class in
Main.vb is a different class not having any buttons anymore, therefore
the
error.

Now I could manually also put the whole "Partial Class" into the "Forms"
namespace, but as the file is "designer generated" I can not touch it (or
take the risk that my lines will be overwritten).

I've done this before (in C#) and never had a problem with VS.NET
messing up my namespace declaration in the Main.Designer.cs file after
editing the form.

--
Patrick Steele
http://weblogs.asp.net/psteele


Feb 12 '07 #5
On 2007-02-11, Armin Zingler <az*******@freenet.dewrote:
"Tom Shelton" <to*********@comcastXXXXXXX.netschrieb
>On 2007-02-11, Armin Zingler <az*******@freenet.dewrote:
Hi all,

I have a Form called "Main":

Public Class Main

Private Sub Button1_Click( _
ByVal sender As System.Object, ByVal e As
System.EventArgs) _ Handles Button1.Click

End Sub

End Class
Now I want to put the form into a namespace called "Forms". If I
put the lines "Namespace Forms" and "end namespace" before and
after the code above, I get an error at the "Handles" clause.
Reason: The "Partial Class" in Main.Designer.vb is still in the
old Namespace. Consequently the class in Main.vb is a different
class not having any buttons anymore, therefore the error.

Now I could manually also put the whole "Partial Class" into the
"Forms" namespace, but as the file is "designer generated" I can
not touch it (or take the risk that my lines will be overwritten).

So, how do I move a Form into a namespace in VB 2005? This was no
problem in VB 2003 because it was all one file.
Armin

Just change it and make your default namespace the new namespace.
You should have a problem with it... At least, I haven't in c# :)

Uhm, sorry, but I don't understand. What should I change? The designer
generated file?
Yes. Just change the namespace declaration in the designer file.
Why should I have a problem with it?
I meant you should not have a problem. It was a typo.
I don't want to change
the default namespace (you mean the root namespace of the project?), I only
want to put the Form in the Namespace.
I see, you already changed it and you are moving the form into it... Then just
change the designer file. It shouldn't cause any issues.

--
Tom Shelton
Feb 12 '07 #6
"Tom Shelton" <to*********@comcastXXXXXXX.netschrieb
Just change it and make your default namespace the new
namespace. You should have a problem with it... At least, I
haven't in c# :)
Uhm, sorry, but I don't understand. What should I change? The
designer generated file?

Yes. Just change the namespace declaration in the designer file.
Why should I have a problem with it?

I meant you should not have a problem. It was a typo.
Ah, I see.
>I don't want to change
the default namespace (you mean the root namespace of the project?), I
only
want to put the Form in the Namespace.

I see, you already changed it and you are moving the form into it... Then
just
change the designer file. It shouldn't cause any issues.
Ok, I'll try.

Thanks Tom.
Armin

Feb 12 '07 #7
"Patrick Steele" <pa*****@mvps.orgschrieb
In article <Oy**************@TK2MSFTNGP05.phx.gbl>,
az*******@freenet.de says...
Now I want to put the form into a namespace called "Forms". If I
put the lines "Namespace Forms" and "end namespace" before and
after the code above, I get an error at the "Handles" clause.
Reason: The "Partial Class" in Main.Designer.vb is still in the
old Namespace. Consequently the class in Main.vb is a different
class not having any buttons anymore, therefore the error.

Now I could manually also put the whole "Partial Class" into the
"Forms" namespace, but as the file is "designer generated" I can
not touch it (or take the risk that my lines will be overwritten).

I've done this before (in C#) and never had a problem with VS.NET
messing up my namespace declaration in the Main.Designer.cs file
after editing the form.
Ok, seems to be save. I'll try it.

Thanks Patrick.
Armin
Feb 12 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SSRoy | last post by:
Hi all, The type library is an important file for COM interop, without which unmanaged code can't interact with managed code. When I use .NET 2003, I can sucessfully generate .tlb file from a .NET...
1
by: RA | last post by:
Hi I wonder if anyone tried this or know if it has been fixed. I am using vs .net 1.1 and have a windows form. In the form I have a DataGrid with the following format: 3 first Columns are of...
4
by: Sumit Gupta | last post by:
Hi Can any one tell me how to move a form without titlebar as we can use WIn API in VB 6.0 is there any other method or xyz for the same Sumit
6
by: Ryan | last post by:
I have 2 forms, Form1.vb and Form2.vb. In Solution Explorer, Form2.vb no longer shows a Form icon nor do I have the option to open Form2.vb in the main explorer window where usually I have the...
0
by: Antro | last post by:
Hi, i'm using visual C# 2005. I've got two forms, frmMain and frmCalendar. At the minute i am opening frmCalendar which ive created in the visual studio like this, frmCalendar fmCalendar = new...
6
by: =?Utf-8?B?Unlhbg==?= | last post by:
I have three forms in my application; frmMain being the main form: frmMain containing two button; btnDisplayForm1 and btnDisplayForm2 FormA containing a button btnProcessRequestA FormB containing...
3
by: =?Utf-8?B?Umlja1NlYW4=?= | last post by:
I have a form with many text boxes; how do I implement Tool Tip for all text boxes withour using MouseHover method for each individual textbox?
0
by: Hillbilly | last post by:
Right now I have a shitload of form data in an event handler I will need to reuse in other event handlers in the same page. Using firstName1 and firstName2 for strings can't possibly be the way I...
0
by: peridian | last post by:
Hi, Apparently, even if you set the database type to 2000, when you create a database in 2005, it is marked as 2005 regardless, and you cannot then mount the files on a 2000 installation. This...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.