如何在一个BUTTON过程中调用另一个BUTTON的过程

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        procedure Button2Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button2Click(Sender: TObject);
    begin
      ShowMessage('Button2Click');
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Button2Click(nil);
    end;end.
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Showmessage('button1 procedure');
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      Button1.Click;
    end;
      

  3.   

    button1过程,bttton2调用
    这样写:在button2的onclick事件里边button1.onclick(sender);
    其实最好是用sender参数自动判断事件触发的是什么控件if sender is button1 then
    if sender if button2 then with (sender as Tbutton2) do ....
      

  4.   

    insert2003(高级打字员)Button1.onClick(nil);-----------------------------------
    正解!!