473,507 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to copy a form

If I create a form and add add a bunch of controls and code, etc to it, I
can see that Visual Studio adds all of the requisite "creation" code behind
the form.

If I wanted to create a 2nd copy of the exact form, how would I go about
that? Could I just copy the code from the first form, including the
Windows-generated code, and paste it in the code-behind of the 2nd form? I
see that there is a warning not to modify the code-behind using the code
editor, but to instead use the Form Designer. Does that mean what I ask is a
bad idea?

If so, what's the easiest way to add a 2nd form with exactly the same
controls, events, etc?

Thanks.
May 12 '06 #1
4 6059
mrmagoo wrote:
If I create a form and add add a bunch of controls and code, etc to it, I
can see that Visual Studio adds all of the requisite "creation" code behind
the form.

If I wanted to create a 2nd copy of the exact form, how would I go about
that? Could I just copy the code from the first form, including the
Windows-generated code, and paste it in the code-behind of the 2nd form? I
see that there is a warning not to modify the code-behind using the code
editor, but to instead use the Form Designer. Does that mean what I ask is a
bad idea?

If so, what's the easiest way to add a 2nd form with exactly the same
controls, events, etc?

Thanks.


No, your way will work fine. You could also just copy the .vb files for
it and add it to your new project. The warning is just, a warning, you
can make changes but if you do something incorrect the designer might
not work. Make sure to change the class name once you copy it.

Chris
May 12 '06 #2
Thanks!

"Chris" <no@spam.com> wrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
mrmagoo wrote:
If I create a form and add add a bunch of controls and code, etc to it, I can see that Visual Studio adds all of the requisite "creation" code behind the form.

If I wanted to create a 2nd copy of the exact form, how would I go about
that? Could I just copy the code from the first form, including the
Windows-generated code, and paste it in the code-behind of the 2nd form? I see that there is a warning not to modify the code-behind using the code
editor, but to instead use the Form Designer. Does that mean what I ask is a bad idea?

If so, what's the easiest way to add a 2nd form with exactly the same
controls, events, etc?

Thanks.


No, your way will work fine. You could also just copy the .vb files for
it and add it to your new project. The warning is just, a warning, you
can make changes but if you do something incorrect the designer might
not work. Make sure to change the class name once you copy it.

Chris

May 12 '06 #3
Everytime I try your approach, I seem to screw up the designer code somehow.
I have reverted to creating a new form then copying all the controls to it.
--
Dennis in Houston
"mrmagoo" wrote:
Thanks!

"Chris" <no@spam.com> wrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
mrmagoo wrote:
If I create a form and add add a bunch of controls and code, etc to it, I can see that Visual Studio adds all of the requisite "creation" code behind the form.

If I wanted to create a 2nd copy of the exact form, how would I go about
that? Could I just copy the code from the first form, including the
Windows-generated code, and paste it in the code-behind of the 2nd form? I see that there is a warning not to modify the code-behind using the code
editor, but to instead use the Form Designer. Does that mean what I ask is a bad idea?

If so, what's the easiest way to add a 2nd form with exactly the same
controls, events, etc?

Thanks.


No, your way will work fine. You could also just copy the .vb files for
it and add it to your new project. The warning is just, a warning, you
can make changes but if you do something incorrect the designer might
not work. Make sure to change the class name once you copy it.

Chris


May 12 '06 #4
I just do it by copying and pasting the form, in the solutions explorer in
the designer. You just need to change the class name and the form name in
the initialisation code (it will come up as a compiler error so it's easy to
find).

HTH
Simon

--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD

Tel: 0870 080 2300
Fax: 0870 735 0011

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
Everytime I try your approach, I seem to screw up the designer code
somehow.
I have reverted to creating a new form then copying all the controls to
it.
--
Dennis in Houston
"mrmagoo" wrote:
Thanks!

"Chris" <no@spam.com> wrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
> mrmagoo wrote:
> > If I create a form and add add a bunch of controls and code, etc to
> > it,

I
> > can see that Visual Studio adds all of the requisite "creation" code

behind
> > the form.
> >
> > If I wanted to create a 2nd copy of the exact form, how would I go
> > about
> > that? Could I just copy the code from the first form, including the
> > Windows-generated code, and paste it in the code-behind of the 2nd
> > form?

I
> > see that there is a warning not to modify the code-behind using the
> > code
> > editor, but to instead use the Form Designer. Does that mean what I
> > ask

is a
> > bad idea?
> >
> > If so, what's the easiest way to add a 2nd form with exactly the same
> > controls, events, etc?
> >
> > Thanks.
> >
> >
>
> No, your way will work fine. You could also just copy the .vb files
> for
> it and add it to your new project. The warning is just, a warning, you
> can make changes but if you do something incorrect the designer might
> not work. Make sure to change the class name once you copy it.
>
> Chris


May 13 '06 #5

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

Similar topics

4
32191
by: Risto Heinonen | last post by:
Hi. I have a web page that has images and text. I can carefully select one image and the on the right of the image and then copy & paste to Word. Is it possible to make javascript do the same:...
6
10443
by: Shyguy | last post by:
I want to create two buttons on a form. One would allow the user to Copy the contents of the current records memo field, the other would allow them to print. I set up a report based on the memo...
3
8337
by: Tlm | last post by:
Hello All, I have a form (FrmA) with a subform (SubFrmB) embedded in it. SubFrmB also has a subform embedded in it (SubFrmC) The form's recordsource is based on a table (TblA). SubFrmB's...
3
3198
by: david | last post by:
Hi, I've been reading tons of posts on how to copy records, but to no avail....i'm still stuck. There are three tables: Main, Sub-Form1 & Sub-Form2 I have a form which displays some data....
19
3442
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
22
5055
by: Woody Splawn | last post by:
I am somewhat new to VS.net in general. As a result I am prone to make mistakes. When adding some new feature to a a form it would be nice if I could back it up before trying something that might...
3
1575
by: puzzlecracker | last post by:
Given, class X { //..... private: auto_ptr<Y> y; };
5
13953
by: Kaur | last post by:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two...
5
11090
by: phill86 | last post by:
Hi I have a main form that holds records for scheduled meetings, date time location etc... in that form i have a sub form that has a list of equipment resources that you can assign to the meeting in...
0
7114
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
7321
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,...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.