在数据库的datagridview中显示图像 [英] Show image in datagridview from database

查看:303
本文介绍了在数据库的datagridview中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将图像保存在我的访问数据库中.现在,在检索的同时,我可以轻松地使用流在picturebox中设置图像.但我想在按钮上单击以显示datagridview中的所有图像(因为它们是数据库中的多个图像).怎么做.下面我给了我如何在picturebox中设置图像的代码.指导我在gridview中显示数据库的所有图像.

i have saved images on my access database. now while retrieving i can easily use stream to set the image in picturebox. but i want to show all images in datagridview (as thier are mulitple images in database)on button click. how to do so. below i have given code how i am setting image in picturebox.guide me to show all images of my database in gridview..

OleDbDataAdapter dp = new OleDbDataAdapter(str, con);
                DataTable table = new DataTable("myTable");
                DataSet ds = new DataSet("snaps1");
                byte[] MyData = new byte[0];
                dp.Fill(ds, "snaps1");
                DataRow myRow;
                myRow = ds.Tables["snaps1"].Rows[0];
                toolStripStatusLabel2.Text = myRow["imagedescription"].ToString();
                MyData = (byte[])myRow["snaps"];
                MemoryStream stream = new MemoryStream(MyData);
                //With the code below, you are in fact converting the byte array of image
                //to the real image.
                pictureBox1.BackgroundImage = Image.FromStream(stream);
                pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;

推荐答案

^ ]


检查这些链接
编辑DataGrid中的几乎所有内容
http://csharp.net-informations.com/datagridview/csharp-datagridview-image.htm
http://johnroach .info/2012/01/13/how-to-add-images-to-datagridview-cell-using-c-and-windows-forms/
Check these link
Edit Almost Anything in a DataGrid
http://csharp.net-informations.com/datagridview/csharp-datagridview-image.htm
http://johnroach.info/2012/01/13/how-to-add-images-to-datagridview-cell-using-c-and-windows-forms/


浏览这些链接
在DataGridView中预览图像缩略图 [ http://stackoverflow.com/questions/8984715/show-image- in-specific-cell-datagridview-c-sharp [ ^ ]
Go through these links
Image Thumbnail Preview in DataGridView[^]
http://stackoverflow.com/questions/8984715/show-image-in-specific-cell-datagridview-c-sharp[^]


这篇关于在数据库的datagridview中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆