It's easy and fun to create setup components at design time, but if you must, it's not difficult to create them at run time as well.
//
// assuming: your form is called "Form1"
//
with TLabel.Create( Form1 ) do
begin
Parent := Form1; // this is important
Left := 50; // X coordinate
Top := 60; // Y coordinate
Caption := 'hello, world';
//
// set your other parameters here...
//
//
// you don't have to set the Name
// parameter, but...
//
Name := 'Label1';
//
// finally make it visible
//
Visible := True;
end;
// assuming: your form is called "Form1"
//
with TLabel.Create( Form1 ) do
begin
Parent := Form1; // this is important
Left := 50; // X coordinate
Top := 60; // Y coordinate
Caption := 'hello, world';
//
// set your other parameters here...
//
//
// you don't have to set the Name
// parameter, but...
//
Name := 'Label1';
//
// finally make it visible
//
Visible := True;
end;
Listing #1 : Delphi code. Download runtime (0.39 KB).
var
l : TLabel;
begin
//
// assuming: your form is called "Form1"
//
l := TLabel.Create( Form1 );
l.Parent := Form1; // this is important
l.Left := 50; // X coordinate
l.Top := 60; // Y coordinate
l.Caption := 'hello, world';
//
// set your other parameters here...
//
//
// you don't have to set the Name
// parameter, but...
//
l.Name := 'Label1';
//
// finally make it visible
//
l.Visible := True;
end;
l : TLabel;
begin
//
// assuming: your form is called "Form1"
//
l := TLabel.Create( Form1 );
l.Parent := Form1; // this is important
l.Left := 50; // X coordinate
l.Top := 60; // Y coordinate
l.Caption := 'hello, world';
//
// set your other parameters here...
//
//
// you don't have to set the Name
// parameter, but...
//
l.Name := 'Label1';
//
// finally make it visible
//
l.Visible := True;
end;
Listing #2 : Delphi code. Download runtime2 (0.4 KB).