Datagridview不更新/刷新 [英] Datagridview not updating/refreshing
问题描述
我有一个DataGridView由一个来自DB的表的DataSet组成。当我删除一行时,它会在数据库中更新,但不会从GridView中删除。只有当我重新启动应用程序时,它才会从GridView中移除。
请帮忙
1)创建一个绑定源
2。)将此对象的数据源设置为您的数据集表。
3.)将DatagridView的数据源设置为绑定源对象。
代码示例:
Dataset ds = new Dataset();
BindingSource bs = new BindingSource()
bs.Datasource = ds.Table [0];
DatagridView.Datasource = bs;
现在,您在DataTable中所做的任何更改都会自动影响到您的GridView。
I have a DataGridView made of a DataSet of a table from the DB. When I delete a row, it is updated in the database but it is not removed from the GridView. Only when I restart the application does it get removed from the GridView.
Please help
This is a very simple process.
1.) Create a Binding Source
2.) Set the Datasource for this object to your Dataset Table.
3.) Set The datasource for your DatagridView as the Binding source Object.
Code Example:
Dataset ds = new Dataset();
BindingSource bs = new BindingSource()
bs.Datasource = ds.Table[0];
DatagridView.Datasource = bs;
Now, Any changes you make in the DataTable will ripple through to your GridView automatically.
这篇关于Datagridview不更新/刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!