可以先定义一个结构体
TNewButton = Record
 btn:TBuuton;
 Id:Integer;
 Info:String;
 ...
end;定义动态数组 
 btnArr : array of TNewButton;
当你动态建立Button的时候保存按钮相关信息
button := TButton.Create(Applicaiton);
button.OnClick := btnOnclick;
...
setlengh(btnArr,length(btnArr)+1);
with btnArr[Length(btnArr)-1) do begin
    //用tag记录在数组中的编号
    button.tag := length(btnArr) -1;
    btn := Button ;
    
    //加入代码记录关于此按钮的其他信息end;
//在btnOnClick中
if sender is TButton  then begin
  //显示相关信息,当然也可以是做其他的操作
   Form.Titile := btnArr[(Sender As TButton).tag].info;
   。 
end;

解决方案 »

  1.   

    procedure TForm1.MyClick(Sender: TObject);
    begin
       if (Sender is Tbutton) then
           Form1.Caption := IntToStr((Sender as TButton).Tag);
    end;procedure TForm1.testClick(Sender: TObject);
    var
      button1:array[1..9] of tButton;
      i:integer;
    begin
      for i:=1 to 9 do
      begin
        button1[i]:= TButton.Create(self);
        button1[i].top:=0+i*30;
        button1[i].left:=0;
        button1[i].Parent:=self;
        button1[i].Caption := IntToStr(i);
        button1[i].tag:=i;
        button1[i].onclick:=MyClick;
      end;
    end;