请举例说明。谢谢

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, DB, DBTables;type
      TForm1 = class(TForm)
        DataSource1: TDataSource;
        Table1: TTable;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure btnclick(sender:Tobject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure Tform1.btnclick(sender:Tobject);
    begin
      showmessage('you click');
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      btn:Tbutton;
    begin
       btn:=Tbutton.Create(self);
       btn.Parent:=form1;
       btn.Top:=20;
       btn.Left:=20;
       btn.OnClick:=btnclick;
       btn.Show;
    end;end.
      

  2.   

    同意99guo(小兵) 的,把btn.OnClick赋为一个自定义的过程