Hi Tassilo
It is also permitted to create labels (or any other widows object) dynamically, but positioning is the main issue. Still it is a useful technique if the number is not known in advance. Here is a typical example, but be warned - windows objects consume a surprising amount of resource, and often non-windows objects (such as speed-buttons) or using a string array are to be preferred.
Quote
type
tMainForm = class( TForm)
...
private
iMyLabel : array[ 1..cMaxLabelCount ] of tLabel;
public
procedure CreateLabels(ActualCount : integer);
end;
procedure TMainForm.CreateLabels(ActualCount : integer);
var
i, iTop : integer;
begin
iTop := 20;
for i := 1 to ActualCount do
begin
iMyLabel[i] := tLabel.Create( self );
with iMyLabel do
begin
Parent := self;
Left := 20;
Top := iTop;
inc( iTop, 20 );
Label.Caption := ValueStr[ i ];
Show;
end;
end;
end;
You will see, compared to the visual + assignment method, there is a lot involved!
Regards
Merlin :magic: