c# Winform间的页面传值

Form2

public partial class Form2 : Form

{

    public string str;

    public Form2()

    {

        InitializeComponent();

    }



    private void button1_Click(object sender, EventArgs e)

    {

        str = textBox1.Text;

        Form3 f3 = new Form3();

        f3.ShowDialog(this);

    }

}

Form3

public partial class Form3 : Form

{

    public Form3()

    {

        InitializeComponent();

    }



    private void Form3_Load(object sender, EventArgs e)

    {

        Form2 f2 = (Form2)this.Owner;

        MessageBox.Show(f2.str);

    }

}

 

或者直接把Form1中的textBox的属性设为Public

你可能感兴趣的:(WinForm)