作者:admin 来源: 日期:2020/3/22 22:12:41 人气: 标签:
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;//或许可以继续精练一下