我如何访问 aDataSet和它TablesData(s)从另一个类添加/删除/编辑行
我有一个WinForm,我添加了
DataGridViewdataGridView1DataSetdataSet1- 将它们与
BindingSource
所有数据都将保存在 XML 中
一切正常,我做了几个测试项目一切正常
但是当我尝试测试从另一个类中添加数据行的可能性时,它没有显示更改DataGridView!!!!
所以我有Form1,dataGridView1两者dataSet1都是public
在我做的另一堂课中
var esf = new Form1();
DataRow pl = esf.dataSet1.Tables["MyItems"].NewRow();
pl["Type"] = type;
pl["Name"] = true;
esf.dataSet1.Tables["MyItems"].Rows.Add(pl);
如果我添加
esf.dataSet1.WriteXml(esf.XmlSettingsFile);
它正确保存文件!
但它会覆盖其他数据
我觉得我正在使用与DataSet表单中的原始数据相同的另一个数据,但我需要DataSet在主表单中访问原始数据
只是我需要拥有dataSet1aspublic static这样我就可以访问它并向它添加编辑数据,但是当我这样做时,Visual Studio 给了我错误!在表单的视觉视图中!?!
有什么建议么