Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
12. Mär 2003, 12:47
Ich würde es so machen:
Delphi-Quellcode:
procedure TForm1.myLabelClick(Sender: TObject);
begin
if Sender is TLabel then
begin
case (Sender as TLabel).Tag of
0: ShowMessage(IntToStr((Sender as TLabel).Tag));
1: ShowMessage(IntToStr((Sender as TLabel).Tag));
2: ShowMessage(IntToStr((Sender as TLabel).Tag));
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
myLabelArray: array of TLabel;
i : Integer;
begin
setlength(myLabelArray, 3);
for i := 0 to 2 do
begin
myLabelArray[i] := TLabel.Create(self);
myLabelArray[i].Parent := Form1;
myLabelArray[i].Left := 20;
myLabelArray[i].Top := 20*i+1;
myLabelArray[i].Caption := IntToStr(i);
myLabelArray[i].OnClick := myLabelClick;
myLabelArray[i].Tag := i;
end;
end;
Michael Ein Teil meines Codes würde euch verunsichern.
|