第一个button1.onclick已经编码完毕~
现在button2.onclick事件和button1的一样~(只是接受参数的不同。)不想把代码在复制一下!
如果将button1.onclick事件在button2中继承一下啊~请指教 ~~

解决方案 »

  1.   

    你写的要求不详细
    将BTN2的ONCLICK的属性付值为BTN1的ONCLICK(ONCLICK有个下拉COMBOX),如果两个BTN的接受参数不同,可用SENDER来调用,如if sender.tag =XXX then
      

  2.   

    对,写个过程,接受不同的参数,然后在两个button中用不同的参数调用这个过程。
      

  3.   

    1、直接在button2的event里onclick上选button1.onclick
    2、在button2的onclick事件里 写一行代码
       button1.Click;就酱~
      

  4.   

    一个简单的例子:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        procedure FormCreate(Sender: TObject);
      private
        procedure ButtonClick(Sender: TObject);
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
      Button1.Tag := 1;
      Button2.Tag := 2;
      Button1.OnClick := ButtonClick;
      Button2.OnClick := ButtonClick;
    end;procedure TForm1.ButtonClick(Sender: TObject);
    begin
      case TButton(Sender).Tag of
        1: ShowMessage ('You push the button 1');
        2: ShowMessage ('You push the button 2');
      end;
    end;end.
      

  5.   

    button2.onclick = yourfunction;把这个方法直接负值过去就好了。、
    或者是自己写过程,调用button1 的事件函数,然后同样的扶植 就可以了。
      

  6.   

    1、直接在button2的event里onclick上选button1.onclick
    2、在button2的onclick事件里 写一行代码
       button1.Click;