Rashid Khan

Rashid Khan

  • NA
  • 159
  • 0

how to show images in datagirdview form imagefolder?

Oct 9 2013 7:37 AM
I m trying to bind datagridview from images which are stores in imagefolder dynamically.

i have try this

 System.IO.DirectoryInfo inputDir = new System.IO.DirectoryInfo("ImageFolder Path which are in my application");
            try
            {
                if ((inputDir.Exists))
                {
                   
                    System.IO.FileInfo file = null;

                    foreach (System.IO.FileInfo eachfile in inputDir.GetFiles())
                    {
                        file = eachfile;
                        if (file.Extension.ToLower() == ".jpg")
                        {
                            

                           
                            DataGridViewImageColumn imageColumn = new DataGridViewImageColumn();
                            imageColumn.Name = "ImageColumn";
                            imageColumn.HeaderText = "An Image!";
                            var imagepath = file.FullName;
                           Image image = System.Drawing.Image.FromFile(file.FullName);
                            imageColumn.Image = image;
                            dataGridView1.Columns.Insert(0, imageColumn);
            
                        }
                        i++;
                    }
                            

on designer side. I places datagridview (empty).
in out put only columns header show . not a single image load.

please tell me how to show images in datagridview.

Answers (1)