Hello,
Currently I'm developing simple chat client.
I want to know how to pass data from one form to another form but at the same form.
For Example I have two Form which is Form1 and Form2.
Form1 can generate Form2 many times but which different Form2 just the Form2.text (the name)
So, I Open Form1 and click the button to create two Form2. Lets say the first Form2.text = "FirstForm2" and the second Form2.text ="SecondForm2"
The problem is, how to keep sending new data (updating the data) to others form without needed to close the form and can be chosen.
My intention is to add new information into the textbox on the other form. (not to create new one, but update the FirstForm2 that has been opened unless it has been closed then create a new one).
Form1 Code:
private void btnSend_Click(object sender, System.EventArgs e)
{
// Through Constructor
Form2 frm = new Form2();
frm.loadDis(textBox1.Text);
frm.Show();
}
/* to create new form*/
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.Text = username;
frm.Show();
}
Form2 Code:
internal void loadDis(String dis)
{
label1.Text = dis;
}