Hello! Can somebody help me. It's got to be quite easy but still I can't solve the problem.
I have Form1 then I press the button and create another Form2. If I click the button for example three times there will be three Form2. All the Forms have textBox. What I want is from one Form2 sent the text to anothe Form2.
That's my code. But the only thing that I can do is to send messages between Form1 and Form2
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
List<Form> frm = new List<Form>();
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
frm.Add(f);
f.Owner = this;
string s = this.textBox1.Text;
f.textBox1.Text = this.textBox1.Text;
f.Show();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}
///And for Form2
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form1 main = this.Owner as Form1;
if (main != null)
{
string s = main.textBox1.Text;
main.textBox1.Text = this.textBox1.Text;
}
}