更新时间:2023-12-06 17:07:04
要渲染,你必须使用图像的 DataGridViewImageColumn 列。您也可以使用 CellPainting
事件吸取/漆图像/每个或特定的细胞绘制。
To render an image you have to use DataGridViewImageColumn column. You can also use CellPainting
event to draw/paint image/drawing on each or specific cell.
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex==1 && e.ColumnIndex==1)
{
using (Image img = Image.FromFile(@"c:\file\file.gif"))
{
e.Graphics.DrawImage(img, e.CellBounds.Left, e.CellBounds.Top - 1, e.CellBounds.Right, e.CellBounds.Bottom - 1);
e.PaintContent(e.ClipBounds);
e.Handled = true;
}
}
}