Windows窗体:TableAdapter和数据集 [英] Windows Forms: TableAdapter and DataSets

查看:124
本文介绍了Windows窗体:TableAdapter和数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有两种形式(Form1和amp2). Form1包含一个DataGridView控件及其相关的数据集和TableAdapter.如何在Form2中访问它们?我想这样写:

Hi all,

I have two forms (Form1 & Form2). Form1 contains a DataGridView control and its related dataset and TableAdapter. How do I access them in Form2? I would like to write it like this:

addressTableAdapter1.Update(mpRetailDataSet1); //by creating objects of them is not working



请举一个例子.



[原件.标题]
如何在另一个Windows窗体中获取TableAdapter和DataGridView的数据集



Please reply with an example.



[orig. title]
how to get TableAdapter and DataSet of DataGridView in Another Windows Form

推荐答案

根据哪个窗体创建另一个窗体,在创建的窗体中设置一个公共属性设置为DataSet和TableAdapter.

因此,如果Form1创建Form2,则Form2具有:
Depending on which form creates the other, set up a public property in the created form which set to the DataSet and TableAdapter.

So, if Form1 create Form2, then Form2 has:
public DataSet dataToManipulate {get; set;}
public TableAdapter tableToManipulate {get; set;}


和Form1:


And Form1:

Form2 frm = new Form2();
frm.dataToManipulate = myDataSet;
frm.tableToManipulate = myTableAdapter;
frm.ShowDialog();


这篇关于Windows窗体:TableAdapter和数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆