Cells["picture"]就是存储图片的那一列。获取方法如下:
object pic_value = this.dgView.SelectedRows[0].Cells["picture"].Value;
Form f = new Form();
f.BackgroundImage = GetImageByBytes((byte[])pic_value);
f.Show();
public static Image GetImageByBytes(byte[] bytes)
{
try
{
if (bytes.Length == 0) return null;
Image photo = null;
using (MemoryStream ms = new MemoryStream(bytes))
{
ms.Write(bytes, 0, bytes.Length);
photo = Image.FromStream(ms, true);
} return photo;
}
catch
{
return null;
}
}
object pic_value = this.dgView.SelectedRows[0].Cells["picture"].Value;
Form f = new Form();
f.BackgroundImage = GetImageByBytes((byte[])pic_value);
f.Show();
public static Image GetImageByBytes(byte[] bytes)
{
try
{
if (bytes.Length == 0) return null;
Image photo = null;
using (MemoryStream ms = new MemoryStream(bytes))
{
ms.Write(bytes, 0, bytes.Length);
photo = Image.FromStream(ms, true);
} return photo;
}
catch
{
return null;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货