很简单, 呵呵:
procedure TForm1.Button1Click(Sender: TObject);
var
I, J: integer;
begin
for I := 1 to 16do
for J := 1 to 4do
begin
with TSpeedButton.Create(Panel1)do
begin
top := 10 + (j - 1) * 30;
left := 10 + (i - 1) * 30;
Parent := Panel1;
visible := True;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
I, J: integer;
begin
for I := 1 to 16do
for J := 1 to 4do
begin
with TCheckBox.Create(Panel1)do
begin
top := 10 + (j - 1) * 30;
left := 10 + (i - 1) * 50;
Parent := Panel1;
Caption := Format('c%d,%d', [I, J]);
visible := True;
end;
end;
end;