7

我正在使用 TFlowPanel,并且在运行时我在其上创建了可变数量的控件(在此示例中为 TButton)。我想在每个控件之间创建一个边距,但它还不起作用。

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;

例子

任何想法为什么?

问候和感谢,丹尼斯

4

1 回答 1

4

您需要将 AlignWithMargins 设置为 true,因此在您的代码中将是:

LButton.AlignWithMargins := true;
于 2017-08-05T14:33:50.053 回答