我是一个刚学DEIPHI的,最近有一个问题请大家看看
如果我要在form1中读取form2的一个控件的属性通过变量传递怎么实现
非常感谢!

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
        With TForm2.Create(nil) do
        begin
            Edit1.Text:='您好';
        end;
    end;
      

  2.   

    前提:
    1。form2创建
    2。form1[unit1单元] 中引用unit2单元
    uses 
      unit2;button1.Caption := form2.edit1.text;{也可以在form2中定义全局变量替代之}
      

  3.   

    当然了,Form1中首先要引用Form2的单元文件...
    var
      Form1: TForm1;implementationuses Unit2;{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    begin
        With TForm2.Create(nil) do
        begin
            Edit1.Text:='您好';
        end;
    end;
    {$R *.DFM}
    ...
      

  4.   

    Form1所在单元中加入Form2所在单元,如Uses Unit2,保证该成员是公有(Public)!直接调用!如:Form2.Button1.Caption!