Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / May 2006

Tip: Looking for answers? Try searching our database.

How to copy a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mrmagoo - 12 May 2006 16:35 GMT
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.
Chris - 12 May 2006 16:45 GMT
> 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
[quoted text clipped - 11 lines]
>
> 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
mrmagoo - 12 May 2006 18:19 GMT
Thanks!

> > 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
[quoted text clipped - 18 lines]
>
> Chris
Dennis - 13 May 2006 00:43 GMT
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.
Signature

Dennis in Houston

> Thanks!
>
[quoted text clipped - 24 lines]
> >
> > Chris
Simon Verona - 13 May 2006 09:15 GMT
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

Signature

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

Tel: 0870 080 2300
Fax: 0870 735 0011

> Everytime I try your approach, I seem to screw up the designer code
> somehow.
[quoted text clipped - 35 lines]
>> >
>> > Chris

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.