[英]How can I replace numbers in a data grid view with images?
我从数据库中收到一个分配给我的数据网格的表,但是我想用图像替换“标签”列中的数字,但是这样做有问题。 目前,我尝试使用一个数字没有成功。 列的类型为文本框,但将其更改为图像对我也不起作用。
我尝试使用CellFormating,但可以找到我感兴趣的字段,但是我不知道如何用图像替换数字。
private void DgvCriticasUser_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dgvCriticasUser.Columns[e.ColumnIndex].Name == "tag")
{
if (e.Value.ToString() == "1")
{
Bitmap tag1 = (Bitmap)Bitmap.FromFile(@"C:\Users\guill\Desktop\ProyectoIntegradoVerde-master\ProyectoEquipoVerde\ProyectoEquipoVerde\imagenes\grupo_w.png");
DataGridViewImageCell iCell = new DataGridViewImageCell();
iCell.Value = tag1;
e.Value = iCell;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.