在C#中的DataSet和之间的DataGridView数据绑定 [英] DataBinding between DataSet and DataGridView in C#

查看:1145
本文介绍了在C#中的DataSet和之间的DataGridView数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个窗体上的DataGridView,我想用DataSet中的一个DataTable,从(使用System.Data.SQlite)SQLite数据库填充使用。

I currently have a DataGridView on a form which I want to use with a DataTable in a DataSet, populated from a SQlite database (using System.Data.SQlite).

所以,我有数据库和数据集之间的一个DataAdapter,可以直接设置DataGridView的数据源作为数据表。这显示细腻

So, I have a DataAdapter between the database and DataSet and can set the DataGridView data source directly as the DataTable. This displays fine.

我的问题是这样的:
我为什么要在这里使用绑定源?很多教程说你可以使用与否。但是有什么用呢,不是增加一个额外的步骤等?

My question is this: Why would I want to use a Binding Source here? Many tutorials have said you can use it or not. But is there any use for it, other than adding an extra step?

另外,如果我想在DataGridView的改变要更新的数据库,这怎么可能做了什么?是数据集自动更新 - 所以我只需要告诉DataAdapter的更新吗?或者是那里有一个绑定源是有用的?

Also, if I want the database to be updated when the DataGridView is changed, how can this be done? Is the DataSet automatically updated - so I just need to tell the DataAdapter to update? Or is there where a binding source is useful?

谢谢!

推荐答案

为别人寻找这一点,我发现为什么要使用绑定源的这里

For anyone else searching for this, I found a good description of why to use a Binding Source here.

同样的这个解释保存/恢复在DataGridView所做的更改。

Similarly, this explains saving/restoring changes made in the DataGridView.

希望帮助别人!

这篇关于在C#中的DataSet和之间的DataGridView数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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