1.主窗体
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.refreshlist += Frm2_refreshlist;
frm2.ShowDialog();
}
private void Frm2_refreshlist()
{
MessageBox.Show("列表刷新了");
}
}
2.子窗体
public partial class Form2 : Form
{
public event Action refreshlist;
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
this.Dispose();
if (refreshlist != null)
{
refreshlist();
}
}
}