C#WinForm DataGridView控件显示图片问题DataGridView显示数据库相对路径的图片!!显示不出!非2进制...求解

解决方案 »

  1.   

    你存的是图片路径?
     byte[] readbyte = new byte[byte.MaxValue];
     FileStream fs = new FileStream("图片路径" ,FileMode.OpenOrCreate, FileAccess.ReadWrite);
     fs.Read(readbyte, 0, readbyte.Length);
     Image img = Image.FromStream(fs);
     讲读到的图片加进数据源就可以了
      

  2.   

    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;   }   
    使用DataGridViewImageColumn   
    DataGridViewImageColumn column = new DataGridViewImageColumn();   
    dataGridView1.Columns.Add(column);   
    column.HeaderText = "图片";   
    column.Image = System.Drawing.Image.FromFile("路径");   ((DataGridViewImageCell)this.dataGridView1.Rows[e.RowIndex].Cells[ "图片列"]).Value = "路经 "