How backup or copy form

  • Thread starter Thread starter Woody Splawn
  • Start date Start date
W

Woody Splawn

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.
 
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.
--------------------
 
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
 
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.
--------------------
 
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
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.
 
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?
 
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?
 
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
 
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
 
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.
--------------------
 
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.
 
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
 
Hi,
What is a complicated form design inside VB.net? See my last post
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.
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.
--------------------
<[email protected]>
<[email protected]>
 
I'm sorry Cor

I am unable to understand what the message below means. I have tried
but I honestly don't understand it.
 
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.
 
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?
 
Hi Peter,

Is there anything to look out for, other than what I mention below ,
when copying a simple form?
 
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?
 
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
 
Back
Top