亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Winform在DataGridView中顯示圖片

 更新時(shí)間:2016年05月30日 11:51:57   作者:秦風(fēng)  
本文主要介紹在DataGridView如何顯示圖片,簡(jiǎn)單實(shí)用,需要的朋友可以參考下。

首先,要添加圖片列,綁定數(shù)據(jù)的時(shí)候會(huì)觸發(fā)CellFormatting事件,在事件中取出圖片路徑,讀取圖片賦值給當(dāng)前單元格。

private void dataGridview1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
  if (dataGridview1.Columns[e.ColumnIndex].Name.Equals("Image"))
  {
    string path = e.Value.ToString();
    e.Value = GetImage(path);
  }
}
public System.Drawing.Image GetImage(string path)
{
  System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open);
  System.Drawing.Image result = System.Drawing.Image.FromStream(fs);

  fs.Close();

  return result;

} 

以上就是DataGridView如何顯示圖片一些代碼片段,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論