我要实现的效果是,在控件表面点击按钮跳出winform窗口,跳出窗口的作用是添加数据,当关闭这个这个窗口后,刷新上一级窗口显示添加的数据。
我想通过窗体的owener属性实现,但是在存在usercontrol类型和form类型转换的问题。
请问各位有什么方法解决或者告之另外的实现思路!!!
------解决方案--------------------------------------------------------
- C# code
public partial class UserControl1 : UserControl { public delegate void RefreshWindowHandler(); public event RefreshWindowHandler OnRefreshWindow; public UserControl1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form frm = new Form(); frm.FormClosing += (sender1, e1) => { if (OnRefreshWindow != null) { OnRefreshWindow(); } }; frm.Show(); } }this.userControl11.OnRefreshWindow += () => { MessageBox.Show("刷新窗体"); };