hi i want to show images in datagrid

here i m having database.. in that i was stored image path..

so I was retrieved database path values and i want to show those images in datagrid

how to do this in windows application using c#..


need ur suggestions

regards
thaha hussain

Welcome @thaha01

Take a look at this code and try to understand how to display image on grid.

public class SampleImage
        {
            public string Path { get; set; }
            public Image Content { get; set; }
        }
        public class SampleImages : List<SampleImage> { }


        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.AutoGenerateColumns = false;
            DataGridViewImageColumn col1 = new DataGridViewImageColumn();
            col1.DataPropertyName = "Content";
            col1.ImageLayout = DataGridViewImageCellLayout.Stretch;
             

            dataGridView1.Columns.Add(col1);
             
            SampleImages images = new SampleImages()
            {
                new SampleImage(){ 
                     Path=@"x:\folder\Images\one.jpg",
                     Content=Image.FromFile(@"x:\folder\Images\one.jpg")
                },
                 new SampleImage(){ 
                     Path=@"x:\folder\Images\two.jpg",
                     Content=Image.FromFile(@"x:\folder\Images\two.jpg")
                }
                
            };

            dataGridView1.DataSource = images;
        }

Please read members rules at daniweb - http://www.daniweb.com/forums/faq.php?faq=daniweb_policies and homework policy.

i want to show images in datagrid view from a folder.
in that folder i store image and its name store in sql database and than i want to retrive a prticular image by its name that is find image name from database table.

how to do this in windows application using c#..
plz give your suggestion
Regrds.
David Saini

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.