Cannot set the BackColor of datagridview cell in virtual mode (2.5.32)

Answered
0
0

Hi,

we have recently upgraded to 2.5.32 and found an issue with datagridview when in virtual mode. In the handler of CellValueNeeded, in addition to set values, we also set the backcolor of the cell. It was working well with 2.2.14 before the upgrade to 2.5.32. But now the backColor doesn’t change with the same code.

It still works for datagridview without virtual mode.

Thanks

  • You must to post comments
Best Answer
0
0

Hi
Comments about your code

CellValueNeeded is fired when the virtual cell needs the value and the only thing to do is to assign e.Value.

Using gv.Rows[e.RowIndex][colBalance].Style.BackColor = Color.LightBlue he’s causing the creating of all the rows and all the cells while the grid is responding to a data request making the virtual mode useless

Solution
Use the event CellFormating
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
e.CellStyle.BackColor = Color.Green;
}

Now in Wisej-Net DataGridView is using a fully virtual row system
The color is save correctly by wisej, if you hit refresh you see it.

More details about DatagridView you can see in Wisej-Net documentation

Hth

 

  • Weitian Lou
    Hi Paul, yes, it works. Thanks a lot for your support!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.