I want form2 to pass the text in textbox to form1 when it closes.
I have 2 forms as shown in photo. when form2 is opened and when I enter a text then click "send text to form1" nothing happen, the text wont pass to form1 (form2 closes but the textbox in form1 still empty).
I do not know what is wrong. can anyone help me what to do? thank you
Form1:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show();
textBox1.Text = frm2.p;
}
}
Form2:
public partial class Form2 : Form
{
string a;
public string p
{
get { return a; }
}
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
a = textBox1.Text;
this.Close();
}
}

frm2.phasn't been set yet. Once you set it inbutton1_Clickin form2, you need to tell form 1 to update again. - Ron Beyera,pfrm2, etc. are much harder to understand than meaningful variable names. - Servy