I have a table, where one of the columns is of the image type. When using the "ImageLayout" attribute as "Stretch" the background is black. How can I change it to white?
I'm using the "SystemIcons" icon set converted to a bipmap.
private Bitmap GetIcone()
{
return SystemIcons.Warning.ToBitmap();
}
And inserting this way:
row.Cells["ColStatusIcone"].Value = GetIcone(status.icone);
Edit: İf you want to change background color to white only Image cells:
dataGridView1.CellFormatting += (x, y) =>
{
if (y.DesiredType == typeof(Image)){
y.CellStyle.BackColor = Color.White;
}
};
You can try to change your image columns' color to white on CellFormattingEvent. Try this:
dataGridView1.CellFormatting += (x, y) =>
{
if (y.ColumnIndex != 1) //your image cell index
{
return;
}
y.CellStyle.BackColor = Color.White;
};