473,395 Members | 1,556 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,395 software developers and data experts.

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 4195
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**********************************@microsof t.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******@totallybogus.comwrote in message
news:ue**************@TK2MSFTNGP02.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**********************************@microsof t.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**********************************@microsof t.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**********************************@microsof t.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**********************************@microsof t.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**********************************@microso ft.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**********************************@microsof t.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**********************************@microsof t.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**********************************@microsof t.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**********************************@microso ft.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**********************************@microso ft.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
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...
1
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...
22
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...
5
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...
5
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...
4
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...
5
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...
13
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...
11
by: Dijkstra | last post by:
Hi folks! First, this is the code I'm using to expose the problem: ------------------------------------------------------------------ #include <functional> #include <string> #include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.