PC Review


Reply
Thread Tools Rate Thread

Copy a form (for reuse) in a project?

 
 
=?Utf-8?B?VGVycnk=?=
Guest
Posts: n/a
 
      14th Nov 2007
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
 
Reply With Quote
 
 
 
 
eBob.com
Guest
Posts: n/a
 
      15th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:A6E908AD-CCDA-4BA5-8C57-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Imran Shaik
Guest
Posts: n/a
 
      15th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:A6E908AD-CCDA-4BA5-8C57-(E-Mail Removed)...
>> 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

>
>


 
Reply With Quote
 
=?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=
Guest
Posts: n/a
 
      15th Nov 2007
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

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      15th Nov 2007
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

 
Reply With Quote
 
CMM
Guest
Posts: n/a
 
      15th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:A6E908AD-CCDA-4BA5-8C57-(E-Mail Removed)...
> 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


 
Reply With Quote
 
=?Utf-8?B?VGVycnk=?=
Guest
Posts: n/a
 
      15th Nov 2007
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" <(E-Mail Removed)> wrote in message
> news:A6E908AD-CCDA-4BA5-8C57-(E-Mail Removed)...
> > 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

>

 
Reply With Quote
 
CMM
Guest
Posts: n/a
 
      15th Nov 2007
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" <(E-Mail Removed)> wrote in message
news1538343-8779-4098-95EE-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:A6E908AD-CCDA-4BA5-8C57-(E-Mail Removed)...
>> > 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

>>


 
Reply With Quote
 
=?Utf-8?B?VGVycnk=?=
Guest
Posts: n/a
 
      15th Nov 2007
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" <(E-Mail Removed)> wrote in message
> news1538343-8779-4098-95EE-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> news:A6E908AD-CCDA-4BA5-8C57-(E-Mail Removed)...
> >> > 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
> >>

>

 
Reply With Quote
 
CMM
Guest
Posts: n/a
 
      15th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:5B68D63F-35FF-4632-BFA6-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news1538343-8779-4098-95EE-(E-Mail Removed)...
>> > 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" <(E-Mail Removed)> wrote in message
>> >> news:A6E908AD-CCDA-4BA5-8C57-(E-Mail Removed)...
>> >> > 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
>> >>

>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to design a large .NET Project - Reuse Components aaapaul Microsoft Dot NET 13 23rd Oct 2007 11:31 AM
reuse business methods as DLL in another project?? ashrafnairoukh@yahoo.com Microsoft Dot NET Framework 2 24th Jul 2006 01:03 AM
reuse business methods as DLL in another project ??? ashrafnairoukh@yahoo.com Microsoft Dot NET 0 22nd Jul 2006 05:28 PM
how do i clear and reset a database to reuse it on a new project =?Utf-8?B?UmF5?= Microsoft Access 2 28th Mar 2006 12:24 PM
Reuse code on multiple pages of project =?Utf-8?B?U2FuZHk=?= Microsoft ASP .NET 21 5th Sep 2005 09:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:16 AM.