如何在 WPF 中刷新数据网格 [英] How to refresh datagrid in WPF

查看:21
本文介绍了如何在 WPF 中刷新数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的源在一个 MySQL 数据库中,我已经做了一个更新命令,现在我需要刷新我的 DataGrid.

My source is in a MySQL database, I've made an update command and now I need to refresh my DataGrid.

MySqlCommand cmd = new MySqlCommand(
  "update request set status = " + StatusRequest(value) + 
  " where id = " + rowView[0].ToString() + "", conn);
MySqlDataReader myReader = cmd.ExecuteReader();

如何刷新我的 DataGrid?

推荐答案

更新后重新加载网格的数据源

Reload the datasource of your grid after the update

myGrid.ItemsSource = null;
myGrid.ItemsSource = myDataSource;

这篇关于如何在 WPF 中刷新数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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