I am using the TFlowPanel and at runtime i am creating a variable number of controls (in this example TButton) on it. I want to create a margin between each control, but it doesnt work yet.
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
LButton: TButton;
begin
for i := 0 to 10 do
begin
LButton := TButton.Create(flwpnl1); // flwpnl1 is the TFlowPanel
LButton.Parent := flwpnl1;
LButton.Height := 20;
LButton.Caption := Format('Status%d', [i]);
LButton.Margins.Left := 20;
LButton.Margins.Top := 20;
LButton.Margins.Right := 20;
LButton.Margins.Bottom := 20;
end;
end;
Any ideas why?
Regards and thanks, Dennis
You need to set AlignWithMargins to true, so in your code that would be:
LButton.AlignWithMargins := true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With