【问题标题】:How to update a datagridview with updated sql table in C#?如何在 C# 中使用更新的 sql 表更新 datagridview?
【发布时间】:2014-04-24 20:36:26
【问题描述】:

我在 WinForms 应用程序中有一个 DataGridView,我用数据库中的表填充它(本地数据库,表称为“table”)。当我在 C# 代码中更新表时,更改会在数据库中生效,但不会显示在 DataGridView 中。

如何更新 DGV?我找到了dataGridViewStock.Refresh();dataGridViewStock.Update();,但这两个都不起作用。

有人给我小费吗?

【问题讨论】:

  • 如何绑定datagridview?

标签: c# sql winforms datagridview


【解决方案1】:

在 c# 中更新数据表后,您可以简单地编写

yourDataGridView.DataSource=null;
yourDataGridView.DataSource=dt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多