有2个form,form1中有button1,button2,form2中有label1,
点button1和button2都能调出form2,
点button1调出的form2,label1.caption显示为'button1'
点button2调出的form2,label1.caption显示为'button2'
如何实现?

解决方案 »

  1.   

    Button的OnClick事件里写:Form2.Label1.Caption := TButton(Sender).Name;
    Form2.Show;
      

  2.   

    两个ButtonClick事件里都写,注意在implementation下引用Unit2
      

  3.   

    Button的OnClick事件里写:
    Application.CreateForm(TForm2, Form2);
    if TButton(Sender).name='button1' then
    form2.label1.Caption:='1'
    else if TButton(Sender).name='button2' then
    form2.label1.Caption:='2';
    form2.Show;这样写效果出不来,要怎么样改 ?
      

  4.   

    学习中!
    我想这程序显示用不到if
    用form2的显示去判断form1的操作
    行不通吧?