Datagridview 不更新/刷新 [英] Datagridview not updating/refreshing

查看:103
本文介绍了Datagridview 不更新/刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由数据库中的表的数据集组成的 DataGridView.当我删除一行时,它会在数据库中更新,但不会从 GridView 中删除.只有当我重新启动应用程序时,它才会从 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.

请帮忙

推荐答案

这是一个非常简单的过程.

This is a very simple process.

1.) 创建绑定源

2.) 将此对象的数据源设置为您的数据集表.

2.) Set the Datasource for this object to your Dataset Table.

3.) 将 DatagridView 的数据源设置为绑定源对象.

3.) Set The datasource for your DatagridView as the Binding source Object.

代码示例:

Dataset ds = new Dataset();
BindingSource bs = new BindingSource()
bs.Datasource = ds.Table[0];
DatagridView.Datasource = bs;

现在,您在 DataTable 中所做的任何更改都会自动影响到您的 GridView.

Now, Any changes you make in the DataTable will ripple through to your GridView automatically.

这篇关于Datagridview 不更新/刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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