我有一个表,其中一个列是图像类型的。当使用"ImageLayout“属性作为”拉伸“时,背景是黑色的。我怎么才能把它换成白色?

我正在使用转换为bipmap的"SystemIcons“图标集。
private Bitmap GetIcone()
{
return SystemIcons.Warning.ToBitmap();
}并以这种方式插入:
row.Cells["ColStatusIcone"].Value = GetIcone(status.icone);发布于 2020-06-16 00:03:33
编辑:如果要将背景颜色更改为白色图像单元格,则为İ:
dataGridView1.CellFormatting += (x, y) =>
{
if (y.DesiredType == typeof(Image)){
y.CellStyle.BackColor = Color.White;
}
};您可以尝试在CellFormattingEvent.上将图像列的颜色更改为白色。试试这个:
dataGridView1.CellFormatting += (x, y) =>
{
if (y.ColumnIndex != 1) //your image cell index
{
return;
}
y.CellStyle.BackColor = Color.White;
};https://stackoverflow.com/questions/62398678
复制相似问题