How To Populate DataGridView With Static Data In C Sharp

How To Populate DataGridView With Static Data In C#

How To Populate DataGridView With Static Data In C#
How To Populate DataGridView With Static Data In C#
How To Populate DataGridView With Static Data In C#

C# SOURCE CODE

 //Populate Datagridview On Form Load
            Image firstImage = Image.FromFile("C:/Users/Public/Pictures/Sample Pictures/Chrysanthemum.jpg");
            byte[] imageAsByte = imageToByteArray(firstImage);
            dataGridView1.Rows.Add("Maurice", "Samantha", "Male", "United States Of America", "C:/Users/Public/Pictures/Sample Pictures/Chrysanthemum.jpg", imageAsByte);
            Image secondImage = Image.FromFile("C:/Users/Public/Pictures/Sample Pictures/Desert.jpg");
            byte[] imageAsByte2 = imageToByteArray(secondImage);
            dataGridView1.Rows.Add("Maurice", "Samantha", "Male", "United States Of America", "C:/Users/Public/Pictures/Sample Pictures/Desert.jpg", imageAsByte2);
            Image thirdImage = Image.FromFile("C:/Users/Public/Pictures/Sample Pictures/Hydrangeas.jpg");
            byte[] imageAsByte3 = imageToByteArray(thirdImage);
            dataGridView1.Rows.Add("Maurice", "Samantha", "Male", "United States Of America", "C:/Users/Public/Pictures/Sample Pictures/Hydrangeas.jpg", imageAsByte3);
            Image fourthImage = Image.FromFile("C:/Users/Public/Pictures/Sample Pictures/Jellyfish.jpg");
            byte[] imageAsByte4 = imageToByteArray(fourthImage);
            dataGridView1.Rows.Add("Maurice", "Samantha", "Male", "United States Of America", "C:/Users/Public/Pictures/Sample Pictures/Jellyfish.jpg", imageAsByte4);
            Image fifthImage = Image.FromFile("C:/Users/Public/Pictures/Sample Pictures/Koala.jpg");
            byte[] imageAsByte5 = imageToByteArray(fifthImage);
            dataGridView1.Rows.Add("Maurice", "Samantha", "Male", "United States Of America", "C:/Users/Public/Pictures/Sample Pictures/Koala.jpg", imageAsByte5);

CONVERTING IMAGE TO BYTE ARRAY SOURCE CODE

        //Converting Image To Byte Array Function
        public byte[] imageToByteArray(Image image)
        {

            MemoryStream ms = new MemoryStream();
            image.Save(ms, image.RawFormat);
            return ms.ToArray();
        }
READ MORE  How To Upload A Video On YouTube From A Computer

Leave a Reply

Your email address will not be published. Required fields are marked *