namespace WinFormsApp1
{
public partial class Form1 : Form
{
Form2 child1 = new Form2();
Form3 child2 = new Form3();
private void Form1_Load(object sender, EventArgs e)
{
child1.TopLevel = false;
child2.TopLevel = false;
this.Controls.Add(child1);
this.Controls.Add(child2);
child1.Parent = this.panel1;
child2.Parent = this.panel1;
child1.Text = child2.Text = "";
child1.ControlBox = child2.ControlBox = false;
child1.FormEvent += EventMethod;
child2.FormEvent += EventMethod;
}
private void button1_Click_1(object sender, EventArgs e)
{
child2.Hide();
child1.Show();
}
private void button2_Click(object sender, EventArgs e)
{
child1.Hide();
child2.Show();
}
public void EventMethod(string str)
{
textBox1.Text = str.ToString();
}
}
}
////////////////////////////////////////////
public partial class Form2 : Form
{
public delegate void SendDataHandler1(string message);
public event SendDataHandler1 FormEvent;
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == string.Empty)
{
MessageBox.Show("text input !!");
return;
}
this.FormEvent(textBox1.Text);
}
}