c#Winform間のページ転送

1773 ワード

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);

    }

}

 
あるいはForm 1のtextBoxの属性を直接Publicにする