By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

How backup or copy form

P: n/a
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 copy a
form. Sounds easy, but my experience has been that it is not.

You can copy the form but there are some things that are done internally in
the original form that are not gotten rid of easily. That is, it is not easy
to get the internals of the original form not to point to or remember things
that are indigenous to the orignal report. I could give all the details but
I don't want to be too long in writing, but one example is this. In one
form I have some code that goes like this:

var1.ParentSource = Me

With this line in the original report, if you copy it, apparently, the copy
still thins of ME as the original report. Don't know how to get around
this.

Bottom line on it all is that I wish I had some easy infalible way of
copying a form. Very handy if you can but I haven't found an easy
combination yet.

Anyone.

Nov 20 '05 #1
Share this Question
Share on Google+
22 Replies


P: n/a
Hi Woody,

I think it is difficult to achieve your aim.
Since a form may use many resource, e.g. a dataset, a picture file and etc.
So just backup the form1.cs and form1.resx file will not make sense.

I seems that you want to implement version control. You may try to use the
source safe, which will help you backup and restore your code.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Woody Splawn" <wo***@splawns.com>
Subject: How backup or copy form
Date: Mon, 10 Nov 2003 09:09:42 -0800
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uT**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:155581
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

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 thecopy and add modifications. So the question is, how to backup or copy a
form. Sounds easy, but my experience has been that it is not.

You can copy the form but there are some things that are done internally in
the original form that are not gotten rid of easily. That is, it is not easyto get the internals of the original form not to point to or remember thingsthat are indigenous to the orignal report. I could give all the details butI don't want to be too long in writing, but one example is this. In one
form I have some code that goes like this:

var1.ParentSource = Me

With this line in the original report, if you copy it, apparently, the copy
still thins of ME as the original report. Don't know how to get around
this.

Bottom line on it all is that I wish I had some easy infalible way of
copying a form. Very handy if you can but I haven't found an easy
combination yet.

Anyone.


Nov 20 '05 #2

P: n/a
Cor
Hi Woody,

I do not see many answers, so let me give you also one.

Fergus did once send me a form.vb and he included also the form.resx.

That did work fine and then I thought that I knew what I did forget
everytime.

Maybe it is the same as your problem.

Cor
Nov 20 '05 #3

P: n/a
Hi Woody,

Another way is using the inherited from

You may try to right click on the project and select Add/Add inherited
form, thus, you can add a new form inherits the original form.
And you can distribute the project as the unit.

If you have any question, please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
X-Tomcat-ID: 89510854
References: <uT**************@TK2MSFTNGP09.phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: v-******@online.microsoft.com (Peter Huang)
Organization: Microsoft
Date: Tue, 11 Nov 2003 02:54:49 GMT
Subject: RE: How backup or copy form
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
Message-ID: <l7*************@cpmsftngxa06.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
Lines: 65
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:155733
NNTP-Posting-Host: TOMCATIMPORT2 10.201.218.182

Hi Woody,

I think it is difficult to achieve your aim.
Since a form may use many resource, e.g. a dataset, a picture file and etc.
So just backup the form1.cs and form1.resx file will not make sense.

I seems that you want to implement version control. You may try to use the
source safe, which will help you backup and restore your code.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Woody Splawn" <wo***@splawns.com>
Subject: How backup or copy form
Date: Mon, 10 Nov 2003 09:09:42 -0800
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uT**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:155581
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

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 wayto 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 copy a
form. Sounds easy, but my experience has been that it is not.

You can copy the form but there are some things that are done internally inthe original form that are not gotten rid of easily. That is, it is not

easy
to get the internals of the original form not to point to or remember

things
that are indigenous to the orignal report. I could give all the details

but
I don't want to be too long in writing, but one example is this. In one
form I have some code that goes like this:

var1.ParentSource = Me

With this line in the original report, if you copy it, apparently, the copystill thins of ME as the original report. Don't know how to get around
this.

Bottom line on it all is that I wish I had some easy infalible way of
copying a form. Very handy if you can but I haven't found an easy
combination yet.

Anyone.



Nov 20 '05 #4

P: n/a
> I do not see many answers, so let me give you also one.

Thank you Cor. I would appreciate some additional answers on this. A
correct understanding of how this works can save many hours and headaches.
if you can't copy and rename forms without problems I guess I don't
understand why Microsoft included the Copy, Rename and SaveAs options in VB.
It's kind of like dangling a carrot in front of you that you can't eat
<grin>

Fergus did once send me a form.vb and he included also the form.resx.

That did work fine and then I thought that I knew what I did forget
everytime.

Maybe it is the same as your problem.


I'm sorry Cor I did not quite understand what you said.

Nov 20 '05 #5

P: n/a
Peter,

I think using version control and source safe is overkill for what I am
doing. In some circumestance inheiretance is an option but I see its
usefullness as limited, though very slick. At least for what I am doing.

Beside inheiretance, is there a way to copy the layout, or some of the
layout, of one form to another? I see that I can not just copy and past
Label1 in Form A to form B, but is there some other way to get unbound
labels and fields copied from one form to another?

Nov 20 '05 #6

P: n/a
Thank you for your help Peter.

I find that for simple forms, copying is not too big a deal. At least this
is my impression. I guess I am asking for someone else to confirm. The
problem seems to be with forms that are more complicated. However with a
realitively simple form like a report dialog that simply asks a few
questions and does not have tabs and 1:m relationships etc this seems to
work for me.

Copy the form. Rename the form. Go into the code of the new form and if
the old form was called Contracts, change the line that reads Public Class
Contracts to something like Public Class Contracts2. Also, if there is a
line in the form's code that reads, me.name = "Contracts", change it to
me.name = "Contracts2".

This seems to work for me. I have not yet seen any problems but, do you
think there is something I am missing?

For more complicated forms, if you're not going to use inheiritance, there
may be no other option than to build from scratch, though if the forms are
really similar in purpose, much of the custom code from the original form I
think I can just copy right over.

Anyone?


Nov 20 '05 #7

P: n/a
Cor
Hi Woody
I don't
understand why Microsoft included the Copy, Rename and SaveAs options in VB. It's kind of like dangling a carrot in front of you that you can't eat
<grin>


I think you mean those by instance those 3 useless functions Cut and Copy
the solution explorer or the Save as form in the File, I don't know that
either. Makes me crazy too.
But the Renaming you can do the best in the Solution Explorer. But Copy and
Paste I do Explorer because I never could paste in the solution Explorer.
Doing that in Explorer you can get errors when you only copy the form.vb
file, and Fergus did send to me a form.vb and a form.resx file that went
well. So that was for me a solution.

I add this also although you maybe know it. When you have copied a form.vb
and a form.resx file into a project directory using Explorer you dont see
it. You have to select a form (why don't ask me) and than becomes in top of
the "solution explorer" 5 icons visible.

One of them is "show all files" if you select that all files in the
directory become visible.
And than you can activate a in explorer pasted file. Take care that you
never activate the object directory otherwise you get errors.

If this was not something you did mean, message it, but I cannot promish you
I know an answer because I think I have the same idea and probably problems
as you with this.

Cor



Nov 20 '05 #8

P: n/a
Cor
Hi Woody,

Now I see your message to Peter while the other is already sand,

Copying from controls works.

Cutting means that all properties will be cutted also and pasted with the
control.
Copying means that it will be copied without properties.

When I have to cut and paste a lot, I make first a copy of my form in the
way I did describe in my other message, because than I dont have to set all
the properties again,

That is than a kind of template that I remove afterwards.

I don't know if there is a better way, but when something works for me I use
that.

I hope I did understand you with this message better,

Cor
Nov 20 '05 #9

P: n/a
Hi Woody,

Yes, for simple Form, you can just copy the vb file.
e.g. just copy the Form1.vb and Form1.resx file.
But for complicated form, the method may not work.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Woody Splawn" <wo***@splawns.com>
References: <uT**************@TK2MSFTNGP09.phx.gbl> <l7*************@cpmsftngxa06.phx.gbl>
<Tu**************@cpmsftngxa06.phx.gbl>Subject: Re: How backup or copy form
Date: Tue, 11 Nov 2003 10:45:32 -0800
Lines: 30
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uz**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP10.phx.gblXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:155955
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Thank you for your help Peter.

I find that for simple forms, copying is not too big a deal. At least this
is my impression. I guess I am asking for someone else to confirm. The
problem seems to be with forms that are more complicated. However with a
realitively simple form like a report dialog that simply asks a few
questions and does not have tabs and 1:m relationships etc this seems to
work for me.

Copy the form. Rename the form. Go into the code of the new form and if
the old form was called Contracts, change the line that reads Public Class
Contracts to something like Public Class Contracts2. Also, if there is a
line in the form's code that reads, me.name = "Contracts", change it to
me.name = "Contracts2".

This seems to work for me. I have not yet seen any problems but, do you
think there is something I am missing?

For more complicated forms, if you're not going to use inheiritance, there
may be no other option than to build from scratch, though if the forms are
really similar in purpose, much of the custom code from the original form I
think I can just copy right over.

Anyone?



Nov 20 '05 #10

P: n/a
Hi Woody,
Beside inheiretance, is there a way to copy the layout, or some of the
layout, of one form to another? I see that I can not just copy and past
Label1 in Form A to form B, but is there some other way to get unbound
labels and fields copied from one form to another?


I can copy the label ,button and etc. controls from one form to another by
using copy and paste.
But the layout will not be copied in the meantime, I think this is by
design.
Another way for you to perserve the layout when copying is to use the
usercontrol, so that you can move a usercontrol from one form to another
with the layout of the controls in the usercontrol. That is to say you need
to use the component development.
If you have any question about this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #11

P: n/a
Cor
Hi Peter,

Will you explain me wh, I am intrested in that also?
Yes, for simple Form, you can just copy the vb file.
e.g. just copy the Form1.vb and Form1.resx file.
But for complicated form, the method may not work.


What is a complicated form design inside VB.net?

Cor
Nov 20 '05 #12

P: n/a
Hi,
What is a complicated form design inside VB.net? See my last postSince a form may use many resource, e.g. a dataset, a picture file and etc.
So just backup the form1.cs and form1.resx file will not make sense. A form may contain many things, except the common button or unbind listbox.
A bind listbox may be concern about a dataset.
Or if there is a thirty party control, then how do you know which file the
control will need to make it work.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------From: "Cor" <no*@non.com>
References: <uT**************@TK2MSFTNGP09.phx.gbl> <l7*************@cpmsftngxa06.phx.gbl>
<Tu**************@cpmsftngxa06.phx.gbl>
<uz**************@TK2MSFTNGP10.phx.gbl>
<QA**************@cpmsftngxa06.phx.gbl>Subject: Re: How backup or copy form
Date: Wed, 12 Nov 2003 08:47:06 +0100
Lines: 13
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#g**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: ip3e830773.speed.planet.nl 62.131.7.115
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156098
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi Peter,

Will you explain me wh, I am intrested in that also?
Yes, for simple Form, you can just copy the vb file.
e.g. just copy the Form1.vb and Form1.resx file.
But for complicated form, the method may not work.


What is a complicated form design inside VB.net?

Cor


Nov 20 '05 #13

P: n/a
I'm sorry Cor

I am unable to understand what the message below means. I have tried
but I honestly don't understand it.
Fergus did once send me a form.vb and he included also the form.resx.

That did work fine and then I thought that I knew what I did forget
everytime.

Maybe it is the same as your problem.


Nov 20 '05 #14

P: n/a
Cutting means that all properties will be cutted also and pasted with the
control.
Copying means that it will be copied without properties.
Cor. What is the source of your information? I have looked in the help
files for information on Copy, Past and Cut and can not find anything. I
thought cutting had to do with cutting the form from one place and moving it
to another. Where can I find more information with regard to properties?
Are you a Microsoft employee?

I'm sorry, it is difficult for me to understand what is being said below. I
don't quite understand what you mean.

When I have to cut and paste a lot, I make first a copy of my form in the
way I did describe in my other message, because than I dont have to set all the properties again,

That is than a kind of template that I remove afterwards.

I don't know if there is a better way, but when something works for me I use that.

I hope I did understand you with this message better,

Cor

Nov 20 '05 #15

P: n/a
> I can copy the label ,button and etc. controls from one form to another by
using copy and paste.
Yes, I don't know what the problem was yesterday but today I see that I can
indeed copy and past controls from one form to another.
Another way for you to perserve the layout when copying is to use the
usercontrol, so that you can move a usercontrol from one form to another
with the layout of the controls in the usercontrol. That is to say you need to use the component development.


I'm not sure what you mean by this. What do you mean by "Use the user
control"? Do you mean, for example, that I could put a Panel on form A with
various controls in it and then copy that panel from form a to form B? Is
this what you're getting at?


Nov 20 '05 #16

P: n/a
Hi Peter,

Is there anything to look out for, other than what I mention below ,
when copying a simple form?
Copy the form. Rename the form. Go into the code of the new form and if
the old form was called Contracts, change the line that reads Public Class
Contracts to something like Public Class Contracts2. Also, if there is a
line in the form's code that reads, me.name = "Contracts", change it to
me.name = "Contracts2".

Nov 20 '05 #17

P: n/a
>A form may contain many things, except the common button

Hi Peter,

It was not clear to me what you meant by the line above. When I copy a
simple form and it has a button on it, it seems to copy alright. Did I
mis-understand you?

Nov 20 '05 #18

P: n/a
Hi Cor,

I'm sorry, I did not quite understand the lines below. What did you mean?
Take care that you
never activate the object directory otherwise you get errors.

Nov 20 '05 #19

P: n/a
Cor
Hi Woody,

Two sentences in the same thread of you one after each other
Beside inheiretance, is there a way to copy the layout, or some of the
layout, of one form to another? I see that I can not just copy and past
Label1 in Form A to form B, but is there some other way to get unbound
labels and fields copied from one form to another? What is the source of your information? I have looked in the help
files for information on Copy, Past and Cut and can not find anything. I
thought cutting had to do with cutting the form from one place and moving it to another. Where can I find more information with regard to properties?


But of course you don't understand this.

Cor
Nov 20 '05 #20

P: n/a
>But of course you don't understand this.

This is correct. I did not understand what you were trying to say in the
last message at all.

I'm not trying to be smart. I am trying to be polite.


Nov 20 '05 #21

P: n/a
Hi Woody,

Comment in lines.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Woody Splawn" <wo***@splawns.com>
References: <uT**************@TK2MSFTNGP09.phx.gbl> <l7*************@cpmsftngxa06.phx.gbl>
<#v**************@TK2MSFTNGP12.phx.gbl>
<SV**************@cpmsftngxa06.phx.gbl>Subject: Re: How backup or copy form
Date: Wed, 12 Nov 2003 08:57:05 -0800
Lines: 20
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uK**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156186
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
I can copy the label ,button and etc. controls from one form to another by using copy and paste.
Yes, I don't know what the problem was yesterday but today I see that I can
indeed copy and past controls from one form to another.


Cheers.
Another way for you to perserve the layout when copying is to use the
usercontrol, so that you can move a usercontrol from one form to another
with the layout of the controls in the usercontrol. That is to say you

need
to use the component development.


I'm not sure what you mean by this. What do you mean by "Use the user
control"? Do you mean, for example, that I could put a Panel on form A

withvarious controls in it and then copy that panel from form a to form B? Is
this what you're getting at?

Yes, a panel is a way for layout. But it will not copy the code too.
My suggestion is that you can make a usercontrol(Windows Control Library),
so that you can move the control with the code too.




Nov 20 '05 #22

P: n/a
Hi Woody,
It was not clear to me what you meant by the line above. When I copy a
simple form and it has a button on it, it seems to copy alright. Did I
mis-understand you?
Yes, you got my meaning, I am sorry for confusion.
If you have any question on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------From: "Woody Spawn" <wo***@splawns.com>
References: <uT**************@TK2MSFTNGP09.phx.gbl> <l7*************@cpmsftngxa06.phx.gbl>
<Tu**************@cpmsftngxa06.phx.gbl>
<uz**************@TK2MSFTNGP10.phx.gbl>
<QA**************@cpmsftngxa06.phx.gbl>
<#g**************@TK2MSFTNGP11.phx.gbl>
<9C**************@cpmsftngxa06.phx.gbl>Subject: Re: How backup or copy form
Date: Wed, 12 Nov 2003 09:02:13 -0800
Lines: 10
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <e2**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net 66.60.158.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP09.phx.gblXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156190
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
A form may contain many things, except the common button


Hi Peter,

It was not clear to me what you meant by the line above. When I copy a
simple form and it has a button on it, it seems to copy alright. Did I
mis-understand you?


Nov 20 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.