现在的位置: 首页 > 综合 > 正文

C# 刷新父窗体

2013年06月28日 ⁄ 综合 ⁄ 共 792字 ⁄ 字号 评论关闭

父窗体代码

public delegate void UpdateFpSpread1();//作为异步更新角色列表时用的委托,//最好使用空参数列表,且要定义为//public

 

//刷新代码

private void Re_Load()

{

...

}

调用

子窗体 frm = new 子窗体(new UpdateFpSpread1(Re_Load));

 

 

子窗体

//写一个新的构造函数,参数是之前写好的委托 
private 父窗体.UpdateFpSpread1 UpdateFpHandler; 
public frmEarlierRecord(frmEarlierManage.UpdateFpSpread1 _updateFpHandler) 

            InitializeComponent();
            this.UpdateFpHandler = _updateFpHandler;//委托赋值 
 

 

private void frmEarlierRecord_FormClosing(object sender, FormClosingEventArgs e)
 {
            if (btn_end.Enabled)
           {
                if (MessageBox.Show("没有点击结束按钮,是否退出?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }

            }

            UpdateFpHandler();
}

抱歉!评论已关闭.