VS 2005 C# 关闭子窗口 更新父窗口中的DataGridview控件

来源:互联网 发布:上海知成机械有限公司 编辑:程序博客网 时间:2024/06/06 03:47

近几天写小系统遇到的问题。查了很久网站,最后是自己踩着石头过河……

解决方案如下:

1,父窗口中的DataGridview属性设为public;

     再添加

     public frmForm MotherForm;

2,在父窗口的打开子窗体事件中

    private void btnNewForm(object sender, EventArgs e)
        {
            frmNewForm fnf = new frmNewFrom();
            fnf.MotherForm = this;
            fnf.ShowDialog();
        }

3,在子窗口中

    private void btnEvent(object sender, EventArgs e)

      {

            ............................

            MotherForm.DataGridView.DataSource = null;

            MotherForm.DataGridView.DataSource = //绑定数据源

            ............................

           ok...

       }

 

大概解决流程就这样了,可能还有不足的地方。