想在DEV GridControl控件中,某一列中显示图片,图片没有绘制出来:
Hashtable Images = new Hashtable();
string ImagesDir = @”F:\QQ头像”;
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
string file = “29864fbda11cbc2bb968ec82b7d6ac89.jpg”;
if (e.Column.FieldName == “Img”&& e.IsGetData)
{
if (!Images.ContainsKey(file))
{
Image img = null;
try
{
string filepath = FilesHelper.FindingFileName(ImagesDir, “29864fbda11cbc2bb968ec82b7d6ac89.jpg”, false);
img = Image.FromFile(filepath);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
Images.Add(file, img);
}
e.Value = Images[file];
}
}
运行后的结果: