你在form2中是重新定义一个form1,当然不行了,你把新定义的form1显示出来就会看到已经赋值成功了!  private void button1_Click(object sender, EventArgs e)
  {  
  Form1 f = new Form1();
  f.t = this.textBox1 .Text ;
  f.show();
  }

解决方案 »

  1.   


      private void button1_Click(object sender, EventArgs e)
      {
      Form2 fm = new Form2(this);//定义fm的时候,要把form1对象传递过去
      fm.Show();
       
      }
      public string t 
      {
      get { return this.textBox1.Text; }
      set { this.textBox1.Text = value; }
      }
    form2中代码:
      //增加定义一个变量保存form1
      private Form1 frm1;
      //修改构造函数
      public Form2(Form1 frm)
      {
        this.frm1=frm; 
      }
      private void button1_Click(object sender, EventArgs e)
      {  
        //对传递过来的from1对象进行修改
        this.frm1.t=this.textBox1 .Text ;
      }
      

  2.   

    public partial class Form1 : Form  
      {  
      private void button1_Click(object sender, EventArgs e)  
      {  
      Form2 frm2 = new Form2();  
      frm2.Show(this);  
      }  
      }    public partial class Form2 : Form  
      {  
      private void button1_Click(object sender, EventArgs e)  
      {  
      Form1 frm1 = (Form1)this.Owner;  
      ((TextBox)frm1.Controls["textBox1"]).Text = this.textBox2.Text;  
      this.Close();  
      }  
      }  

    public string t 
      {
      get { return this.textBox1.Text; }
      set { this.textBox1.Text = value; }
      }
    frm1.t=this.textBox2.Text;  
      

  3.   

    也可以使用委托于事件
     Form2 f = new Form2();
      private void button1_Click(object sender, EventArgs e)
      {
      f.getvalue += new Form2.getvalueHandler(f_getvalue);
      f.Show();
      }
      string f_getvalue()
      {
      return textBox1.Text;
      }
    -----------------form2 代码-----------------------------------------
      public delegate string getvalueHandler();
      public event getvalueHandler getvalue;  private void Form2_Load(object sender, EventArgs e)
      {
      textBox1.Text = getvalue();
      }