I have 2 forms.
I do something wrong when I pass text from form 2 to form 1.
My textbox2 from form 2 doesn't change in my initial form1(are created another form1) when I click on the button, how can I solve it? I want to have only 2 forms, no more.
Code:
public partial class Form1 : Form
{
private string vas;
public Form1()
{
InitializeComponent();
}
public string backsend
{
get { return vas; }
set {vas = value; }
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.passValue = textBox1.Text;
f2.Show();
}
}
public partial class Form2 : Form
{
private string Mn;
public string passValue
{
get { return Mn; }
set { Mn = value; }
}
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
textBox2.Text = Mn;
}
private void button2_Click(object sender, EventArgs e)
{//click for clear textbox1 from form 2.
textBox2.Clear();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1(); i don't understand why is created another form,but not variable
f1.backsend = textBox2.Text;
f1.textBox2.Text = f1.backsend; //no exchange in my first form 1
MessageBox.Show(f1.textBox2.Text);//it's correct
}
}