I'm using Delphi 10.1 and Firemonkey and looking to add controls to a TScrollBox at Runtime and have come across some strange behaviors.
For this example I create Labels and add them to a TScroll box.
The Label is set as TAlignLayout.Top so I assume every new Label created will sit below the previous.
- First Label that gets created goes to the top.
- Second Label that gets created goes below the first.
- Third Label that gets created goes between the first and second Label.
- Any more Labels that created then stacks under the First Label.
I want the Labels to be created from top down in order of creation. Any ideas what I've done wrong?
This is the code to create the Labels:-
procedure TForm1.Button4Click(Sender: TObject);
var
lbFileDate: TLabel;
begin
ScrollBox2.BeginUpdate;
lbFileDate := TLabel.Create(ScrollBox2);
lbFileDate.Parent := ScrollBox2;
lbFileDate.Align := TAlignLayout.Top;
lbFileDate.Text := DateTimeToStr(Now);
ScrollBox2.EndUpdate;
end;
I've done something very similar in Delphi 10.1 VCL and the creation process works by always putting the last Label to the top.
tia