We have an issue with DataGridView’s Cell-Style getting not updated when set within a task using Application.StartTask.
In the attached demo we set some values of a DataGridView but column three is calculated in a task startet with Application.StartTask. Within this task we set the value of the cell and also call Application.Update. Depending on the result we want to apply formating using the CellFormating event. But the updated style is not displayed while the text is shown.
The style is properly updated when reloading the page with F5.
The problem is that the CellStyle in the formatting event is not the style of the cell, changing the properties of the e.CellStyle doesn’t change the cell.Style value, which is correct. But when the update of a few cell values doesn’t trigger a data request, the style change in the formatting event is not “captured” by the small pushed update.
It is a bug that I’ll log.
You can overcome it by either setting the style of the cell, or by using BeginUpdate() and EndUpdate() to let the DGV know that it should reload the data page, which includes also the style values changed in the formatting event:
dataGridView1.Rows.Cells.Value = “c1”;
dataGridView1.Rows.Cells.Value = “c2”;
dataGridView1.Rows.Cells.Value = “c3”;
Please login first to submit.