不行呀。我的程序
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
lblPick: TButton;
begin
for i := 0 to 19 do
begin
lblPick:=TButton.Create(form1);
lblPick.Parent := form1; //注意将其Parent置为容器(一般为Form)
lblPick.Left :=74*(i div 5);
lblPick.Top := (i mod 5)*24;
lblPick.Caption := IntToStr(i+1);
lblPick.Hint :=IntToStr(i+1);
lblPick.Tag:=i;
lblPick.ShowHint :=true;
lblPick.OnClick:=Button2Click;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var ai:integer;
begin
//怎么判断哪个lblPick的Click。
Ai:=lblPick.Tag;//
caption:=inttostr(ai);//返回19。不是我要的。