unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
type mybtn=array[1..10,1..5] of tbutton;
var zjhbtn:mybtn;
i,j:integer;
begin
for i:=1 to 10 do
begin
for j:=1 to 5 do
begin
zjhbtn[i,j]:=tbutton.Create(form1);
zjhbtn[i,j].Parent := form1;
zjhbtn[i,j].Caption :=format('Button[%d,%d]',[i,j]);
zjhbtn[i,j].Left :=zjhbtn[i,j].Width *(j-1)+20*j;
zjhbtn[i,j].Top :=zjhbtn[i,j].height*(i-1)+5*(i +2) ;
zjhbtn[i,j].OnClick:=Button2Click;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage('abc');
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
type mybtn=array[1..10,1..5] of tbutton;
var zjhbtn:mybtn;
i,j:integer;
begin
for i:=1 to 10 do
begin
for j:=1 to 5 do
begin
zjhbtn[i,j]:=tbutton.Create(form1);
zjhbtn[i,j].Parent := form1;
zjhbtn[i,j].Caption :=format('Button[%d,%d]',[i,j]);
zjhbtn[i,j].Left :=zjhbtn[i,j].Width *(j-1)+20*j;
zjhbtn[i,j].Top :=zjhbtn[i,j].height*(i-1)+5*(i +2) ;
zjhbtn[i,j].OnClick:=Button2Click;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage('abc');
end;
end.