DataGridView.CellValueChanged not firing on bound DataGridView

后端 未结 2 1425
暗喜
暗喜 2021-01-21 05:39

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

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-21 05:52

    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;
    

    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

提交回复
热议问题