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);
}
}
'Programming > C#' 카테고리의 다른 글
Action 사용하기 (0) | 2023.09.27 |
---|---|
현재시간(C#) (0) | 2023.09.05 |
기초 C# (0) | 2022.07.13 |
WPF에서 실행파일이 있는 경로 (0) | 2022.07.13 |
WPF 중복 실행 방지 (0) | 2021.12.02 |