picturebox1显示图片用的是绑定的数据源&n

电脑杂谈  发布时间:2018-02-13 13:36:00  来源:网络整理

picturebox图片路径_picturebox1显示图片_picturebox控件

用的是绑定的数据源,想把图片从里面直接读出来,显示到picturebox控件,不知道哪里出的问题显示不出来,也不报错。

privatevoidcategoriesBindingSource_CurrentChanged(objectsender,EventArgse)

{

if(_imageBitmap!=null)

{

_imageBitmap.Dispose();

}

DataRowViewrowView=(DataRowView)categoriesBindingSource.Current;

NorthwindDataSet.CategoriesRowrow=(NorthwindDataSet.CategoriesRow)rowView.Row;

picturebox控件_picturebox1显示图片_picturebox图片路径

byte[]b=(byte[])row.Picture;

if(b.Length>0)

{

System.IO.MemoryStreamstream=newSystem.IO.MemoryStream(b,true);

stream.Write(b,0,b.Length);

pictureBox1.Image=newBitmap(stream);

stream.Close();

}

}

picturebox图片路径_picturebox1显示图片_picturebox控件

}

stream.Write(b,0,b.Length);

去掉试试

你把byte保存成文件看看..能不能用看图工具打开..可能你的byte[]损坏了.

MemoryStreamMS=newMemoryStream((Byte[])row.Picture);

ImagePhoto=Image.FromStream(MS,true);

pictureBox1.Image=Photo;

图片没有损坏,浏览的时候可以直接看到。picturebox1显示图片试了以上所有方法,还是出不来。picturebox1显示图片

“System.Drawing.Image”并不包含“FromStream”的定义

Image对象是哪里,我这段程序用在WM5.0上面在。


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-75504-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...