DataGridView.CellValueChanged不是射击界的DataGridView [英] DataGridView.CellValueChanged not firing on bound DataGridView

查看:135
本文介绍了DataGridView.CellValueChanged不是射击界的DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在一个DataTable编程的方法修改的值我的DataGridView绑定到,适当的CellValueChanged事件不烧成DataGridView的。我想基于在数据表中填充数据,而无需通过每一行迭代和检查每个值单元格的值更改单元格背景颜色。

When I change a value programatically in a DataTable that my DataGridView is bound to, the appropriate CellValueChanged event is not firing for the DataGridView. I'm trying to change a cell's background color based on cell value when the DataTable is filled with data without iterating through every row and checking each value.

推荐答案

您正在改变数据表直接和期望 DataGridView的的事件被解雇?
我建议你编程更改单元格值:

You are changing the DataTable directly and expect DataGridView's event to be fired? I suggest that you change the cell value programatically as:

DataGridView[ColumnIndex, RowIndex].Value = NewValue;

此外,你将不得不呼叫 DataGridView.CommitEdit()提交的值到数据表。这应该触发 CellValueChanged 事件。

Additionally you will have to Call DataGridView.CommitEdit() to commit the values to the DataTable. This should trigger the CellValueChanged event.

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellvaluechanged。 ASPX

这篇关于DataGridView.CellValueChanged不是射击界的DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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