在Delphi中动态创建控件并处理添加事件处理unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;typeTForm1=class(TForm)procedureFormDestroy(Sender:TObject);procedureFormCreate(Sender:TObject);private{Privatedeclarations}public{Publicdeclarations}btn:TButton;procedurebtnClick(Sender:TObject);end;varForm1:TForm1;implementation{$R*.dfm}procedureTForm1.btnClick(Sender:TObject);beginclose;end;procedureTForm1.FormDestroy(Sender:TObject);beginbtn.Free;end;procedureTForm1.FormCreate(Sender:TObject);beginbtn:=TButton.Create(Self);btn.Parent:=Self;btn.Height:=30;btn.Width:=75;btn.Visible:=True;btn.top:=Self.Top+50;btn.Left:=Self.Left+50;btn.Caption:='动态控件';btn.OnClick:=btnClickend;end.