how to make a second copy of a form

  • Thread starter Thread starter TM
  • Start date Start date
T

TM

I have a form that I would like to use, with a few small code and control
text changes, and was wondering if there was any way that I could somehow
save another cop of the form so I can just import it code and all.

Thanks
 
TM said:
I have a form that I would like to use, with a few small code and control
text changes, and was wondering if there was any way that I could somehow
save another cop of the form so I can just import it code and all.

So far all I have been doing is renaming the form and then using Save As...
the original will still be on the drive. Then you just add an existing
form, select the first one and it's back.

Tom
 
TM said:
I have a form that I would like to use, with a few small code and
control text changes, and was wondering if there was any way that I
could somehow save another cop of the form so I can just import it
code and all.

Solution explorer: Select file, Ctrl+C, Ctrl+V
or Drag&Drop holding down the Ctrl key

Maybe it's even better to create two Forms and move the common code to a
common base Form.
 
Armin Zingler said:
Solution explorer: Select file, Ctrl+C, Ctrl+V
or Drag&Drop holding down the Ctrl key

Maybe it's even better to create two Forms and move the common code to a
common base Form.

I might be missing something here, but wouldn't it be simpler to inherit
the base form and apply changes rather than duplicate the code in
another file?

Luke.
 
Luke Vogel said:
I might be missing something here, but wouldn't it be simpler to
inherit the base form and apply changes rather than duplicate the
code in another file?

If you want two Forms to inherit from one base form, you need even three
files (not necessarily but if you want to use the designer) - without having
duplicate code.
 
Not really possible in VB.NET, I assume you are conversant with other
langauges which use templates like C++

Regards - OHM
I have a form that I would like to use, with a few small code and
control text changes, and was wondering if there was any way that I
could somehow save another cop of the form so I can just import it
code and all.

Thanks

Best Regards - OHMBest Regards - OHM (e-mail address removed)
 
* "TM said:
I have a form that I would like to use, with a few small code and control
text changes, and was wondering if there was any way that I could somehow
save another cop of the form so I can just import it code and all.

Develop a common base form and inherit the 2 forms from this form.
 
Herfried,

I think Armin Zingler did give the right answer.
Develop a common base form and inherit the 2 forms from this form.
This could be the intention but not the question.

I think with your answer should also be a sentence as

"Do you know how to do that?

You know only positive ment to keep our quality high.

:-)

Cor
 
* "Cor said:
This could be the intention but not the question.

Yep. I know that. But I think it's the preferred way. I would not
create "copies" of one source file and make little modifications.
 
Tony,
I would recommend the same as Luke & Herfried.

Define a base form with the common functionality then inherit each
specialized version from this common base.

A good place to learn about Inheritance is:
http://msdn.microsoft.com/library/d...us/vbcn7/html/vbconProgrammingWithObjects.asp

For samples of Visual Inheritance, which is used with forms:
http://msdn.microsoft.com/library/d...walkthroughdemonstratingvisualinheritance.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvsm02/html/vs0201gs.asp

Hope this helps
Jay
 
Herfried K. Wagner said:
Yep. I know that. But I think it's the preferred way. I would not
create "copies" of one source file and make little modifications.

That's what I'd have thought. Seems to me that one of the big
advantages of VB.NET and Object Oriented Programming is that of
inheritance, and in this case, visual inheritance lends itself
beautifully to "a few small code and control text changes".

I'm only a newbie myself, but my study of the subject points to
Herfried's answer as the better solution.

Luke.
 
* "Luke Vogel said:
That's what I'd have thought. Seems to me that one of the big
advantages of VB.NET and Object Oriented Programming is that of
inheritance, and in this case, visual inheritance lends itself
beautifully to "a few small code and control text changes".

I'm only a newbie myself, but my study of the subject points to
Herfried's answer as the better solution.

Everybody with < 5 years of experience with .NET (me too) is a "newbie".

;-)
 
Hi Luke


I disagree with you and all others who stated it is that inheritance is the
right answer for this.

If it is about a form with 6 panels on it, on some a tabpage on some a
slider, in a docked panel, than a menu on it, a statusbar, a datagrid with
as in the microsoft samples dataaccess on it, that only needs some changes
for another project and only needs some slight changes, I would not think
one minute about inheriting that form.

When we are talking about making first a nice base form with nice colors we
want to use, a standard statusbar, the fonts etc, I think I agree with you.

Just a thought,

Cor
 
Hi Jay B,

I disagree (in this case not in general), please see my comments at Luke.
I would recommend the same as Luke & Herfried.
This is what I disagree
Define a base form with the common functionality then inherit each
specialized version from this common base.
This is what I agree

Cor
 
If you think about it Cor, using an inherited form makes perfect sense for
some applications. However, I do agree with you that there is a case for
some functionality to allow template forms.

In fact forms inheritance can in some instances be annoying. This can happen
when you want the basic design but need to change some details of the
private members, its more akward really than being able to simply choose a
new form from a tamplate.

Thats what I think anyway.

OHM#




Hi Luke



I disagree with you and all others who stated it is that inheritance
is the right answer for this.

If it is about a form with 6 panels on it, on some a tabpage on some a
slider, in a docked panel, than a menu on it, a statusbar, a datagrid
with as in the microsoft samples dataaccess on it, that only needs
some changes for another project and only needs some slight changes,
I would not think one minute about inheriting that form.

When we are talking about making first a nice base form with nice
colors we want to use, a standard statusbar, the fonts etc, I think I
agree with you.

Just a thought,

Cor

Regards - OHM# (e-mail address removed)
 
* "Cor said:
I disagree with you and all others who stated it is that inheritance is the
right answer for this.

If it is about a form with 6 panels on it, on some a tabpage on some a
slider, in a docked panel, than a menu on it, a statusbar, a datagrid with
as in the microsoft samples dataaccess on it, that only needs some changes
for another project and only needs some slight changes, I would not think
one minute about inheriting that form.

If it's in an other project and you don't wand to use a common class
library, that's the way to go.
 
* "One Handed Man said:
If you think about it Cor, using an inherited form makes perfect sense for
some applications. However, I do agree with you that there is a case for
some functionality to allow template forms.

In fact forms inheritance can in some instances be annoying. This can happen
when you want the basic design but need to change some details of the
private members, its more akward really than being able to simply choose a
new form from a tamplate.

That's why some people prefer to declare "private" variables as
'Protected' instead of 'Private'.
 
Yes, I know how it works. But its a conscious effort to ensure they are
protected. It just can make life a little more complicated. Where sometimes,
you just want to copy the design and not worry about it.

OHM#'

* "One Handed Man [ OHM ]"
If you think about it Cor, using an inherited form makes perfect
sense for some applications. However, I do agree with you that there
is a case for some functionality to allow template forms.

In fact forms inheritance can in some instances be annoying. This
can happen when you want the basic design but need to change some
details of the private members, its more akward really than being
able to simply choose a new form from a tamplate.

That's why some people prefer to declare "private" variables as
'Protected' instead of 'Private'.

Regards - OHM# (e-mail address removed)
 
Cor,
for another project
Is the key word here! The OP never really stated if its the same project or
a different project.

Obviously if its a different project it may be easier just to copy the form
into the second project as you suggest.

However if its the same project then inheritance, most of the time, is the
better method. However in your tab page example, it may be that each tab
page may be its own control, and each distinct form would simply reference a
single extended tab page class...

Hope this helps
Jay
 
Back
Top