I'm trying to use assign on a TPanel
configured in the designer but it doesn't work.
var
LPanel : TPanel;
begin
LPanel := TPanel.Create(nil);
LPanel.Assign(Panel1); // Panel1 is a panel made in the form designer
end;
The error message is something like "TPanel cannot be assigned to TPanel." (I have the german version of RAD Studio... The exact error message on german is "TPanel kann nicht zu TPanel zugewiesen werden.")
I designed a TPanel with other components in it using the Form Designer. Now I want to add new TPanel
instances to a TLayout which should be the same as the TPanel I want to assign from, including all child controls.
Most VCL and FMX components, including TPanel
, DO NOT implement Assign()
at all. Typically only utility classes that are used for component properties implement Assign()
for use in their property setters.
For what you are attempting, you should use a Frame instead of TPanel
. You can design a Frame at design-time, just like a Form or DataModule, and then create instances of it at run-time as needed.
See Embarcadero's documentation for more details: