DataGridView.CellValueChanged does not work with bound DataGridView

When I change the value programmatically in the DataTable to which the DataGridView is bound, the corresponding CellValueChanged event does not fire for the DataGridView. I am trying to change the background color of a cell based on the value of the cell when the DataTable is populated with data without repeating each row and checking each value.

+3
source share
2 answers

Do you change DataTabledirectly and expect the event DataGridViewto be fired? I suggest you change the value of the cell programmatically as follows:

DataGridView[ColumnIndex, RowIndex].Value = NewValue;

, DataGridView.CommitEdit(), DataTable. CellValueChanged.

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

+2

RowPrePaint-Event, , .

0

Source: https://habr.com/ru/post/1739888/


All Articles