窗体1 是MDI。点击MDI中的按钮,show出窗体2 ,窗体2中的内容填写完之后,点击保存此时数据无法添加到MDI的DataGridView里面.

解决方案 »

  1.   

    1 FormA
    private void tsbtnAdd_Click(object sender, EventArgs e)
      {
                FormB  b= new b(this);
                       b.show();
      }FormB
      private    FormB  F1   =   null;
            public FormCustomerOldAddUpdate(FormA  a)
            {
                InitializeComponent();
                F1 = a;
            }
     private void BtnSave_Click(object sender, EventArgs e)
          {
                 DataTable dt = this.F1.dgvList.DataSource as DataTable;
                            DataRow rw = dt.NewRow();
                            rw[0] = txtName.Text;
                            rw[1] = txtLike.Text;
                            dt.Rows.Add(rw);       }FormB中的数据就是无法添加到FormA  的DataGridView中
      

  2.   

    上面写错了
    如下:
    [Quote=引用 1 楼 power0227 的回复:]
    1 FormA
    private void tsbtnAdd_Click(object sender, EventArgs e)
      {
                FormB  b= new FormB(this);
                      b.show();
      }FormB
      private    FormA  F1  =  null;
            public FormCustomerOldAddUpdate(FormA  a)
            {
                InitializeComponent();
                F1 = a;
            }
    private void BtnSave_Click(object sender, EventArgs e)
          {
                DataTable dt = this.F1.dgvList.DataSource as DataTable;
                            DataRow rw = dt.NewRow();
                            rw[0] = txtName.Text;
                            rw[1] = txtLike.Text;
                            dt.Rows.Add(rw);      }FormB中的数据就是无法添加到FormA  的DataGridView中