窗体之间如何传递数据

1.全局变量,你懂的

2.直接通过窗体对象指针传递

//Form1:

Form1->Edit1->Text = "Message";

Form2->Edit1->Text  = Form1->Edit1->Text;

3.通过窗体构造函数传递

// Form1:

TForm2 *Form2  = new TForm2(this,"Message from Form1");

//........

delete Form2;

Form2 = NULL;


//Form2:

__fastcall TForm2::TForm2(TComponent* Owner,String msg)
  :TForm(Owner){

  Message = msg;//message from Form1

}


 

 

4.其他手段,比如消息等比较复杂点

你可能感兴趣的:(String)