type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure MyButtonOnClick(Sender: TObject);//自定义事件
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MyButtonOnClick(Sender: TObject);//自定义事件
begin
showmessage('你的事件');
end;
procedure TForm1.Button1Click(Sender: TObject);
var Button:tbutton;
begin
Button:=TButton.Create(Form1);
Button.Parent:=Form1;
Button.OnClick:=Form1.MyButtonOnClick ;//Button动态创建名
Button.Show;
end;
end.
//其它的也一样的