Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: TFlowPanel margins between each control

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;

Example

Any ideas why?

Regards and thanks, Dennis

like image 790
Dennis F. Avatar asked Aug 19 '16 12:08

Dennis F.


1 Answers

You need to set AlignWithMargins to true, so in your code that would be:

LButton.AlignWithMargins := true;
like image 194
Maya Avatar answered Sep 23 '22 06:09

Maya