现在有两窗口Form1和Form2,现在我想请问下,如何在Form1中获取Form2中的TextBox中的值?

解决方案 »

  1.   

    http://topic.csdn.net/u/20110407/19/c1068d69-7331-4d02-bc0b-f5ba7a5f8dd8.html
      

  2.   

    给你个简单的
    form2里面这样写:
    public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
     public string Txt
            {
                get
                {
           
                    this.textBox1.Text = "这是form2的代码";
                    return this.textBox1.Text;
                }
            }
        }form1里面这样就可以了
     public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show( GetFormTextBoxValle(new Form2()));  
            }        private string GetFormTextBoxValle(Form2 frm)
            {
                if(frm!=null)
                { 
                    return frm.Txt;
                }
                return string.Empty;
            }
        }
      

  3.   

    string.Empty;有点不懂是什么意思…………