C# winForm之间传递参数

来自: 点击打开链接

//窗口1打开窗口2的按钮函数
private void button1_Click(object sender, EventArgs e)
        {
            Form2 fm2 = new Form2();
            fm2.Owner = this;
            fm2.ShowDialog();
        }
//窗口2向窗口1回传数据,假定在窗口2中的TextBox输入数据,在Form1的Label中显示数据
private void buttonOK_Click(object sender, EventArgs e)
        {
            Form1 fm1 = new Form1();
            fm1 = (Form1)this.Owner;
    string data = textBox1.Text;
    fm1.label1.Text = data;
            this.Close();
        }

你可能感兴趣的:(WinForm,C#)