• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 133
  • Last Modified:

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?
0
Enej
Asked:
Enej
  • 2
1 Solution
 
simonetCommented:
First method:

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

type
  TForm2 = class(Form1)
  private
   (...)
  protected
   (...)
  public
   (...)
  published
   (...)
  end;

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.

Yours,

Alex
0
 
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 !
0
 
simonetCommented:
what you did surely works, but there are better ways.

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

Alex
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now