// using System.IO;
DataGridViewImageColumn column = new DataGridViewImageColumn();
column.Name = "画像";
column.Description = "画像";
// 画像の解像度で画像を表示
// column.ImageLayout = DataGridViewImageCellLayout.Normal;
// セルサイズで画像を表示(幅、高さをセルサイズに変更)
// column.ImageLayout = DataGridViewImageCellLayout.Stretch;
// セルサイズで画像を表示(縦横の比率を保持)
column.ImageLayout = DataGridViewImageCellLayout.Zoom;
DataGridView1.Columns.Add(column);
// ("画像",0)セルに画像を表示
using (FileStream fs = new FileStream(@"C:\sample.png", FileMode.Open, FileAccess.Read))
using (Bitmap bmp = new Bitmap(Image.FromStream(fs)))
{
DataGridView1["画像", 0].Value = new Bitmap(bmp);
}
|