Delphi: TFlowPanel fields between each control

I use TFlowPanel and at runtime I create a variable number of controls (in this example TButton). I want to create a difference between each control, but it still does not work.

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

+5
source share
1 answer

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

 LButton.AlignWithMargins := true; 
+1
source

All Articles