473,769 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy a form (for reuse) in a project?

Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in VS
2005 so that it can be modified and reused. In other words, I have a form,
alot of which I wish to use in a different form. An no, I don't want to
inherit it. I just want to steal the layout and add and remove a few other
pieces. Any easy way to do this?

--
Terry
Nov 15 '07 #1
9 4223
I am not sure if this is what you mean, but you can drag and drop several
controls at once from a form in one VS session to a form in another VS
session. I would guess that you can copy and paste too, but I always drag
and drop. And, of course, you can copy and paste the associated code (but
that's a separate operation).

Bob

"Terry" <Te****@nospam. nospamwrote in message
news:A6******** *************** ***********@mic rosoft.com...
Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in VS
2005 so that it can be modified and reused. In other words, I have a
form,
alot of which I wish to use in a different form. An no, I don't want to
inherit it. I just want to steal the layout and add and remove a few
other
pieces. Any easy way to do this?

--
Terry

Nov 15 '07 #2
That would be waste of time as everytime you do that the controls will take
default name like textbox1, button1, button2, and if you copy and paste the
code behind it wont recognise objects associated.

"eBob.com" <fa******@total lybogus.comwrot e in message
news:ue******** ******@TK2MSFTN GP02.phx.gbl...
>I am not sure if this is what you mean, but you can drag and drop several
controls at once from a form in one VS session to a form in another VS
session. I would guess that you can copy and paste too, but I always drag
and drop. And, of course, you can copy and paste the associated code (but
that's a separate operation).

Bob

"Terry" <Te****@nospam. nospamwrote in message
news:A6******** *************** ***********@mic rosoft.com...
>Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in VS
2005 so that it can be modified and reused. In other words, I have a
form,
alot of which I wish to use in a different form. An no, I don't want to
inherit it. I just want to steal the layout and add and remove a few
other
pieces. Any easy way to do this?

--
Terry

Nov 15 '07 #3
I'm pretty sure that what I did before was copy the files making up the form
to new files in the same directory. You can then add them to your project
with "add exisiting...". You will need to change the class names in the
files added, but it seemed painless to me.

"Terry" wrote:
Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in VS
2005 so that it can be modified and reused. In other words, I have a form,
alot of which I wish to use in a different form. An no, I don't want to
inherit it. I just want to steal the layout and add and remove a few other
pieces. Any easy way to do this?

--
Terry
Nov 15 '07 #4
Terry,

For controls, don't Copy them, Cut them and Past them back. I mostly make a
dummy form copied outside the designer to do that from, which gives me a
more secure idea.

Cor

Nov 15 '07 #5
CMM
Select the form in Solution Explorer, right-click and hit Copy. Then, select
the project in Solution Explorer, right-click and hit Paste. Before opening
the newly created copy, hit View Code in Solution Explorer and rename the
class.
That's it.
"Terry" <Te****@nospam. nospamwrote in message
news:A6******** *************** ***********@mic rosoft.com...
Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in VS
2005 so that it can be modified and reused. In other words, I have a
form,
alot of which I wish to use in a different form. An no, I don't want to
inherit it. I just want to steal the layout and add and remove a few
other
pieces. Any easy way to do this?

--
Terry
Nov 15 '07 #6
Ok, this *ALMOST* did it! One important step you left out - exclude the
original form from the project and then open the code behind and rename the
class. Else, it gets renamed in both forms, leaving you with the same
problem of 2 classes with the same name in the project. I had tried all the
of the methods mentioned in the thread, this seems the best if you want to
keep some of the code behind, data bindings etc.

Thanks,
--
Terry
"CMM" wrote:
Select the form in Solution Explorer, right-click and hit Copy. Then, select
the project in Solution Explorer, right-click and hit Paste. Before opening
the newly created copy, hit View Code in Solution Explorer and rename the
class.
That's it.
"Terry" <Te****@nospam. nospamwrote in message
news:A6******** *************** ***********@mic rosoft.com...
Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in VS
2005 so that it can be modified and reused. In other words, I have a
form,
alot of which I wish to use in a different form. An no, I don't want to
inherit it. I just want to steal the layout and add and remove a few
other
pieces. Any easy way to do this?

--
Terry
Nov 15 '07 #7
CMM
This doesn't happen (to me) if I just simply rename the class directly in
the code editor (as I described). DON'T do a Refactor! Symbolic Rename...
because, yeah, that will do what you describe.

"Terry" <Te****@nospam. nospamwrote in message
news:D1******** *************** ***********@mic rosoft.com...
Ok, this *ALMOST* did it! One important step you left out - exclude the
original form from the project and then open the code behind and rename
the
class. Else, it gets renamed in both forms, leaving you with the same
problem of 2 classes with the same name in the project. I had tried all
the
of the methods mentioned in the thread, this seems the best if you want to
keep some of the code behind, data bindings etc.

Thanks,
--
Terry
"CMM" wrote:
>Select the form in Solution Explorer, right-click and hit Copy. Then,
select
the project in Solution Explorer, right-click and hit Paste. Before
opening
the newly created copy, hit View Code in Solution Explorer and rename the
class.
That's it.
"Terry" <Te****@nospam. nospamwrote in message
news:A6******* *************** ************@mi crosoft.com...
Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in
VS
2005 so that it can be modified and reused. In other words, I have a
form,
alot of which I wish to use in a different form. An no, I don't want
to
inherit it. I just want to steal the layout and add and remove a few
other
pieces. Any easy way to do this?

--
Terry
Nov 15 '07 #8
Ok, got it. You edited the name as opposed to right clicking and 'renameing'
the class name.
Thanks again,

--
Terry
"CMM" wrote:
This doesn't happen (to me) if I just simply rename the class directly in
the code editor (as I described). DON'T do a Refactor! Symbolic Rename...
because, yeah, that will do what you describe.

"Terry" <Te****@nospam. nospamwrote in message
news:D1******** *************** ***********@mic rosoft.com...
Ok, this *ALMOST* did it! One important step you left out - exclude the
original form from the project and then open the code behind and rename
the
class. Else, it gets renamed in both forms, leaving you with the same
problem of 2 classes with the same name in the project. I had tried all
the
of the methods mentioned in the thread, this seems the best if you want to
keep some of the code behind, data bindings etc.

Thanks,
--
Terry
"CMM" wrote:
Select the form in Solution Explorer, right-click and hit Copy. Then,
select
the project in Solution Explorer, right-click and hit Paste. Before
opening
the newly created copy, hit View Code in Solution Explorer and rename the
class.
That's it.
"Terry" <Te****@nospam. nospamwrote in message
news:A6******** *************** ***********@mic rosoft.com...
Hi,
Is it possible (w/o generating a gazillion errors) to copy a form in
VS
2005 so that it can be modified and reused. In other words, I have a
form,
alot of which I wish to use in a different form. An no, I don't want
to
inherit it. I just want to steal the layout and add and remove a few
other
pieces. Any easy way to do this?

--
Terry
Nov 15 '07 #9
CMM
Yup. Edit the name directly. The beauty of it is that all the code behind
(partial classes) get renamed too. You only need to do a full "refactor" if
that's... well.... if that's what you want to do. :)

So the steps are:
Select the form in Solution Explorer, right-click and hit Copy. Then, select
the project in Solution Explorer, right-click and hit Paste. Before opening
the newly created form, hit View Code in Solution Explorer and rename the
class *directly* in the code editor (DON'T do right-click->rename). That's
it.

P.S.
This doesn't work as elegantly for webforms (though the steps are similar).
But, then the ASP.NET IDE Designer team have never really done a great job
with anything IMHO.
"Terry" <Te****@nospam. nospamwrote in message
news:5B******** *************** ***********@mic rosoft.com...
Ok, got it. You edited the name as opposed to right clicking and
'renameing'
the class name.
Thanks again,

--
Terry
"CMM" wrote:
>This doesn't happen (to me) if I just simply rename the class directly in
the code editor (as I described). DON'T do a Refactor! Symbolic Rename...
because, yeah, that will do what you describe.

"Terry" <Te****@nospam. nospamwrote in message
news:D1******* *************** ************@mi crosoft.com...
Ok, this *ALMOST* did it! One important step you left out - exclude
the
original form from the project and then open the code behind and rename
the
class. Else, it gets renamed in both forms, leaving you with the same
problem of 2 classes with the same name in the project. I had tried
all
the
of the methods mentioned in the thread, this seems the best if you want
to
keep some of the code behind, data bindings etc.

Thanks,
--
Terry
"CMM" wrote:

Select the form in Solution Explorer, right-click and hit Copy. Then,
select
the project in Solution Explorer, right-click and hit Paste. Before
opening
the newly created copy, hit View Code in Solution Explorer and rename
the
class.
That's it.
"Terry" <Te****@nospam. nospamwrote in message
news:A6******* *************** ************@mi crosoft.com...
Hi,
Is it possible (w/o generating a gazillion errors) to copy a form
in
VS
2005 so that it can be modified and reused. In other words, I have
a
form,
alot of which I wish to use in a different form. An no, I don't
want
to
inherit it. I just want to steal the layout and add and remove a
few
other
pieces. Any easy way to do this?

--
Terry
Nov 15 '07 #10

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

Similar topics

2
1558
by: Mark | last post by:
I have a project management database and it has a form called Estimator that calculates the cost of about 10 parts to a project. You can change parameters, click a Calculate button and all the costs are recalculated. Estimator works great! One of the parts contains an itemized list of up to six components that can be added up to arrive at the cost of that part. The components are listed in a subform sort of like quantity, description and...
1
1266
by: Woody Splawn | last post by:
I have a number of fields on a form in a certain solution. In another solution with a similar form I need to have these same fields. Do I need to create them again from scratch or will it work ok to copy and past from one form in one solution to another form in another solution?
22
5091
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 mess things up. Also, there are times when a new form is enough like an old one that the best way to create the new report is to simply make a copy of the old one, rename the copy and add modifications. So the question is, how to backup or...
5
1449
by: Woody Splawn | last post by:
I seem to remember that you can copy a control, like a textbox AND any code associated with it to another form. Is this true. If so, how? When I select a textbox, for example in form and, copy it and paste it to another form, the control shows up but not any code in any of it's events. Is my memory wrong?
5
1469
by: kirschpe | last post by:
I developed an application using visual studio 2003. Now I want to make a similar application without having to redesign similar forms. Is there a way to copy and paste windows forms across application? I can copy from one to the paste buffer. BUT, there is no corresponding paste on the second application. How can you do this??? tia...
4
2260
by: Mark | last post by:
Good morning. I recently made some changes to my Access project, and I introduced some problems that I could not resolve. So I deleted the forms that I had altered and saved the project. Then I opened my backup copy of the project, and exported the affected forms to the working copy. Now when I invoke any event procedures in the affected forms, I receive the following error (this example is for a click event):
5
1129
by: Benson | last post by:
Since there are many similar programs worked out, I want to copy a similar program (alreay work under form inheritance) to a new one so that I can change the new one quicker. It is not ok to copy under Windows Explorer. How can I do this in VS2005? Benson VS2005, VB2005
13
3971
by: JD | last post by:
Hi, My associate has written a copy constructor for a class. Now I need to add an operator = to the class. Is there a way to do it without change her code (copy constructor) at all? Your help is much appreciated. JD
11
2290
by: Dijkstra | last post by:
Hi folks! First, this is the code I'm using to expose the problem: ------------------------------------------------------------------ #include <functional> #include <string> #include <iostream> using namespace std;
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3965
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 we have to send another system

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.