Code: Select all
public string MyTestBox {
get {return textbox1.Text;}
set {textbox1.Text = value;}
}
Now add the following code to Form1. Then you are able to access the controls of Form2 by using above method.
Code: Select all
Form2 form2;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
form2 = new Form2();
form2.Show();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(form2.MyTestBox);
}