c# - DataGrid绑定(bind)到DataTable时如何刷新DataGrid行?

标签 c# .net wpf datagrid datatable

DataGrid 绑定(bind)到一些DataTable。 用户更改了一些值。我想用一些颜色标记更改的行。 我已经做到了。但是如何通知 DataGrid,当前行值已更改?

附言我在 currentRow.Row.RowState 上使用触发器来指示更改的行。我不想刷新所有 ItemsSource - 它的操作时间太长。

最佳答案

这些方面的一些东西可能有助于交配......它不准确,你可能必须在不同的事件句柄上调用它......但它应该给你一个正确方向的点!

private void dgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            int colIndex = e.ColumnIndex;
            int rowIndex = e.RowIndex;

            DataGridViewRow theRow = dgvOutstandingReports.Rows[rowIndex];


            theRow.DefaultCellStyle.BackColor = Color.LightYellow;
        }

关于c# - DataGrid绑定(bind)到DataTable时如何刷新DataGrid行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11341090/

相关文章:

c# - 在 ASP.Net Repeater 的 jQuery 工具提示中显示 Html 内容

c# - Prism 5.0 在 ViewModel 中包装模型属性

wpf - 应用于所有组合框选定项目的项目

c# - 暂停同步 REST 调用,直到第一个完成

c# - 如何访问 C# 类库中的 HTTP 缓存?

c# - 如何将 HTMLAttributes 传播到自定义 EditorTemplate?

c# - IActionContextAccessor 为空

c# - 用于将 WCF 服务发布到 Azure 的 web.config 更改

c# - 使用 LINQ 对列表中的项目进行排名

wpf - 模型、 View 、 View 模型和演示者