c#中如何实现把一个窗体的值传递到另外一个窗体的文本框里

解决方案 »

  1.   

    在 form2 中,
    再写一个构造函数,参数就是 form1
    这样就可以直接引用form1
     
      

  2.   

    A页面:
    Response.Redirect("B.aspx?Params=3");
    B页面:
    txtBox.Text = Request.QueryString["Params"].ToString();
      

  3.   

    窗体间传值winform间传值  
    通过公共静态类进行传值; 
    通过绑定事件进行传值; 
    使用Attribute 
    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(); 
            } 
        }