Click here to Skip to main content
15,925,723 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..

C#
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;
Posted
Updated 27-Aug-12 2:15am
v3
Comments
pradiprenushe 27-Aug-12 8:06am    
not clear but 'show all images in datagridview column wise on button click'

Its not working for me..how to set image in datagridview from stream..how to view image as small images in the cell. i know DataGridViewImageColumn and its properties can be used but how?? please guide me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900