I ran across this last night when working on Todo 4.0 – apparently there is some sort of bug (or undocumented feature) that makes it so that when you update a cell’s value via the .Value property, the DataGridView itself is not refreshed. Adding or removing rows from a DataGridView causes it to be refreshed and redrawn, but if you edit just the contents of a single cell via the cell.Value property, it doesn’t refresh or redraw the grid. The actual value for the cell is updated, but the displayed value is not updated.
There seem to be a few common ways of fixing this:
- Change the underlying DataSource for the DataGridView and call DataGridView.Refresh()
- Call RefreshEdit() if the row has not already been added to the DataSource (as seen here)
- Remove and re-add the row
I went with the latter. There’s probably a better way to do it, but I couldn’t figure out anything at the time (programming when tired can be a challenge).