C#WinForm DataGridView控件显示图片问题DataGridView显示数据库相对路径的图片!!显示不出!非2进制...求解
解决方案 »
- C#读取access内容显示在Label
- FreeTextBox 控件
- GridControl怎么设置标题栏及搜索结果的字体大小
- C# Winform Teechart学习研究
- 各位大仙,谢谢帮忙了,一个数据库的问题,update
- 请问如何把dbgrid中某一列链接的下化线不显示,谢谢
- 删除javascript的问题!
- 关于AppDomain的一个问题
- 谁能告诉我怎样才可以用c#连接加密ftp(ssl)实现上传下载啊
- c#(or other language)写的程序在没有装dotnet framkwork的windows系统下无法运行吗?
- winform中如何获取动态生成的多个控件的ID~!!!
- c#的winform 中的问题
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);
讲读到的图片加进数据源就可以了
{
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 = "路经 "