Delphi
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure MyClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
xcount=10;
ycount=10;
btwidth=30;
btheight=20;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
x,y:integer;
Button:TButton;
begin
for x:=0 to xcount-1 do
for y:=0 to ycount-1 do begin
Button:=TButton.Create(Form1);
with Button do begin
Parent:=Form1;
Width:=btwidth;
Height:=btheight;
Left:=x*btwidth;
Top:=y*btheight;
onClick:=MyClick;
end;
end;
end;
procedure TForm1.MyClick(Sender:TObject);
begin
with (Sender as TButton) do begin
Tag:=Tag+1;
Caption:=IntToStr(Tag);
end;
end;
end.