在开发中,通常遇见子窗体做某些操作后,会影响父窗体,Demo如下。(通过委托实现)
子窗体定义委托
public delegate void Refreshparent();public event Refreshparent Refreshparent_event;
子窗体调用
private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e){Refreshparent_event();}
父窗体订阅
frmOutDetailEdit frm = new frmOutDetailEdit();frm.Refreshparent_event += new frmOutDetailEdit.Refreshparent(freshthis);frm.ShowDialog()
父窗体触发事件
private void freshthis(){/*需要操作的事项*/}