button1 在 form1窗体上已建立;
按下button1 ,动态产生panel1,button2;panel1的父窗体是form1,button2的父窗体是panel1。
问题出来了,我希望button2也能触发事件。怎样实现按下button2触发一个事件呢?
var
  Form1: TForm1;
  Panel1:TPanel;
  Panel2:TPanel;
  Button2:TButton;
procedure TForm1.Button1Click(Sender: TObject);
begin
  Panel1:=Tpanel.Create(form1);
  panel1.Parent:=form1 ;
  with panel1 do
  begin
    Left := 216;
    Top := 56;
    Width := 569;
    Height := 425 ;
    BevelInner := bvLowered;
    Caption := 'hello';
  end;
  button2:=tbutton.Create(panel2);
  button2.Parent:=panel2;
  with button2 do
  begin
    left:=20;
    top:=20;
    width:=100;
    height:=40;
    caption:='hi!';
  end;
end;
procedure button2click(sender:tobject);
begin
  Panel2:=Tpanel.Create(form1);
  panel2.Parent:=form1 ;
  with panel2 do
  begin
    Left := 216;
    Top := 56;
    Width := 569;
    Height := 425 ;
    BevelInner := bvLowered;
    Caption := 'r   u    ok ?';
  end;
end;
end.
 
运行程序,按下button2没反应,是不是button2的click事件写错了,还是要在哪声明一下?最好能写出代码