Hi,
I am setting Cell background picture in Cell Formatting event.
When for is opened Images are not initially visible, if you click on column header (for sorting) after click background pictures show up.
In Wisej 3.1.2 works OK, upgrade to 3.1.10 break this functionality
private void dgwEntriesDomestic_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
private string docIcon = “Resources\\Icons\\file-pdf-o.svg”;
if (dgwEntriesDomestic.Rows[e.RowIndex].Cells[dgwEntriesDomestic.Columns[“colEntrylinkeddoc”].Index].Value != DBNull.Value)
{
dgwEntriesDomestic.Rows[e.RowIndex].Cells[dgwEntriesDomestic.Columns[“colDoc”].Index].Style.BackgroundImageSource = docIcon;
dgwEntriesDomestic.Rows[e.RowIndex].Cells[dgwEntriesDomestic.Columns[“colDoc”].Index].Style.BackgroundImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
dgwEntriesDomestic.Rows[e.RowIndex].Cells[dgwEntriesDomestic.Columns[“colDoc”].Index].Style.BackgroundImageLayout = ImageLayout.OriginalSize;
}
}
Hi Dino,
this is fixed in our Wisej.NET 3.2.0 release.
Best regards
Frank
In general the CellFormatting event should not be used to update the values or the styles stored with the grid. It’s a formatting event that fires for all cells in all rows for the page (about 100 rows at a time) that is requested by the browser. It allows your code to render a cell value however you want without altering the data. For example a cell that contains “Name” can be rendered as “<b>N</b>name”. Same for colors, images etc.
In the code you pasted executed for all cells in all rows in all columns but it affects only “colDoc” and “colEntrylinkeddoc” and it affects them permanently (potentially updating the data sorce if bound) by setting the value in the cell so there is no need to do that on every formatting (hit refresh and you will see the new values rendered correctly). You can acheive the same result in a better way using e.Value and e.CellStyle and check the e.RowIndex and e.ColumnIndex values.
In any case, this potential regression will be addressed in 3.2.
Please login first to submit.