C# 多种形式的DataGridView和DetailView问题
我正在尝试创建一个多种形式的应用程序,它获取表属性的DataGridView,并在单击按钮后在DetailView中显示它们。当我点击按钮,第二个窗体打开时,它是空的。然后,如果我关闭第二个表单,我会得到“System.NullReferenceException”类型的未处理异常。这是我的密码: 表格一C# 多种形式的DataGridView和DetailView问题,c#,datagridview,detailsview,C#,Datagridview,Detailsview,我正在尝试创建一个多种形式的应用程序,它获取表属性的DataGridView,并在单击按钮后在DetailView中显示它们。当我点击按钮,第二个窗体打开时,它是空的。然后,如果我关闭第二个表单,我会得到“System.NullReferenceException”类型的未处理异常。这是我的密码: 表格一 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MultiForm
{
public partial class Form1 : Form2
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'personnelDataSet.employee' table. You can move, or remove it, as needed.
this.employeeTableAdapter.Fill(this.personnelDataSet.employee);
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnDetails_Click(object sender, EventArgs e)
{
Form2 dForm = new Form2();
dForm.ShowDialog();
this.tableAdapterManager.UpdateAll(this.personnelDataSet);
}
}
}
表格二
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MultiForm
{
public partial class Form2 : Form
{
//public Form2()
//{
// InitializeComponent();
//}
private void employeeBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.employeeBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.personnelDataSet);
}
private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'personnelDataSet.employee' table. You can move, or remove it, as needed.
this.employeeTableAdapter.Fill(this.personnelDataSet.employee);
}
}
}
我在
this.tableAdapterManager.UpdateAll(this.personnelDataSet)的表单1中得到了异常代码>任何帮助都将不胜感激。没有将数据组件拖到托盘中。。。对不起,伙计们