加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Delphi:每个控件之间的TFlowPanel边距

发布时间:2020-12-15 09:51:46 所属栏目:大数据 来源:网络整理
导读:我正在使用TFlowPanel,在运行时我正在创建一个可变数量的控件(在本例中为TButton). 我想在每个控件之间创建一个边距,但它还没有工作. procedure TForm1.FormCreate(Sender: TObject);var i: Integer; LButton: TButton;begin for i := 0 to 10 do begin LBut
我正在使用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;

Example

有什么想法吗?

问候和感谢,
丹尼斯

解决方法

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

LButton.AlignWithMargins := true;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读