Replicate form

I would like to replicate a form
(form1) so I get another (Form2) with
the same components inside (the look).
Meaning :I would like Form2 to have everything Form1 has.What is the
easiest way to do it?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First method:

Use it if you want Form2 to have everything Form1 has plus a few things more.

  TForm2 = class(Form1)

var Form2 : TForm2;

Second method:
If you want Form2 to simply another instance of TForm1, you can simply declare it as such:

var  Form2 : TForm1;

In the case above, the variable name is Form2, but the form's class is TForm1. From this point on you can use with Form2 just like you use Form1.

Remember that if, inside TForm1, you have references to the variable Form1 (instead of using "self"), none of the approaches above will work.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EnejAuthor Commented:
Well,I figured it out myself...
Made Form2 the same size as Form1 and
used the old Cut&Paste method.
(Had many comp. on form and did not
fancy doing everything over again).
Thank you very much !
what you did surely works, but there are better ways.

One of them is to inherit Form2 from Form1, as I pointed out.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.