Nimm BitBtn's die brauchen keinen Groupindex.
Delphi-Quellcode:
implementation
{$R *.dfm}
uses Buttons;
procedure TForm1.FormCreate(Sender: TObject);
const
SPALTEN = 15;
ZEILEN = 15;
var
Button : TBitBtn;
x,y : integer;
begin
for x := 0 to SPALTEN - 1 do begin
for y := 0 to ZEILEN - 1 do begin
Button := TBitBtn.Create(self);
Button.Parent := Scrollbox1;
Button.Caption := 'X';
Button.Width := 32;
Button.Height := 32;
Button.Top := Y * 32;
Button.Left := X * 32;
Button.OnClick := ButtonClick;
Button.Name := 'Button' + intToStr(x) + '_' + inttostr(Y);
end;
end;
end;
procedure TForm1.ButtonClick(Sender : TObject);
begin
// do something...
end;