能否建立二维动态数组控件(100分)

  • 主题发起人 主题发起人 hyne
  • 开始时间 开始时间
H

hyne

Unregistered / Unconfirmed
GUEST, unregistred user!
源码如下,编译通过,运行报错,我晕了,大家帮忙解决解决
SetLength(Ta,2,3);
for I := Low(Ta) to High(Ta)do
begin
for J := Low(Ta) to High(Ta)do
Ta[i,j] := TButton.Create(server);
with Ta[i,j]do
begin
Parent := server.FlatGroupBox6;
Left := 10;
Height := 20;
Width := 30;
Top := 30;
Caption := 'a'+IntToStr(i);
Show;
end;
end;
实在不行我只能一维动态然后手动排序了,大家帮忙解决解决阿
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
// 创建动态按钮,第一排一个,第十排十个
var
b:array of array of TButton;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j:integer;
begin
SetLength(b,10);
for i:=low(b) to high(b)do
SetLength(b,i+1);
for i:=low(b) to high(b)do
for j:=low(b) to high(b)do
begin
b[i,j]:=TButton.Create(self);
with b[i,j]do
begin
parent:=self;
left:=j*30;
top:=i*30;
width:=20;
height:=20;
visible:=true;
end;
end;

end;

end.
 
SetLength(Ta,2,3);
for I := Low(Ta) to High(Ta)do
begin
for J := Low(Ta) to High(Ta)do
begin
Ta[i,j] := TButton.Create(self);
with Ta[i,j]do
begin
Parent := server.FlatGroupBox6;
Left := 10+j*30;
Height := 20;
Width := 30;
Top := i * 20+30;
Caption := 'a'+IntToStr(i);
Show;
end;
end;

end;
 
后退
顶部