本文整理自网络,侵删。
procedure TForm1.Button1Click(Sender: TObject);constiHtoH = 20; //行间距iWtoW = 10; //列间距iPerLine = 6;//每行个数iWidth = 80; //按钮宽度varI : integer;begin//算法:动态创建30个按钮,每行6个共5行,顺序排列,显示在ScrollBox上for I := 1 to 30 do with TButton.Create(Self) do begin Name := 'Btn' + InttoStr(I); Parent := Self.ScrollBox1; Caption := Name; Top := iHtoH + (30+iHtoH) * (I div iPerLine - integer((I mod iPerLine)=0)); Left := iWtoW + (iWidth+iWtoW) * ((I-1) mod iPerLine); Show; end;end;//或许可以继续精练一下
相关阅读 >>
Delphi socket connect timeout 套字节链接超时设置
Delphi firedac 下的 sqlite [9] - 关于排序
更多相关阅读请进入《Delphi》频道 >>