Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:01:53+00:00 2026-06-14T13:01:53+00:00

Right now I am using the following code to populate my third column in

  • 0

Right now I am using the following code to populate my third column in DataGridView:

 Bitmap img = new   
 Bitmap(@"C:\Project\Images\Image1.jpg");
 DataGridView [2, 0].Value = img;           //2,0 is 1st row, 3rd column

 Bitmap img2 = new   
 Bitmap(@"C:\Project\Images\Image2.jpg");
 DataGridView [2, 1].Value = img2;           //2,1 is 2nd row, 3rd column

The third column is correctly populated with the image, but I have this code duplicated 26 more times. For simplicity sake I just want to know if their is a simpler way of doing this, such as making an array or inserting the images directly to my database. I apologize if this is a novice question, by I am relatively new to C#.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:01:56+00:00Added an answer on June 14, 2026 at 1:01 pm

    I would suggest using Directory.GetFiles(path); which gives you array of all files in directory. Using this, you don’t need to worry about the name of the files to be image1,image2,..

    string path = @"C:\Project\Images\";
                string[] arr =  Directory.GetFiles(path);
                for (int i = 0 ; i < arr.Length ; i++)
                {
                    Bitmap img = new Bitmap(Path.Combine(path , arr[i]));
                    DataGridView [2, i].Value = img;
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I am using the following code to update a TextView txtMain.setText(new text);
Right now I'm using the following code in my markup: <asp:HiddenField ID=TheName runat=server Value=<%#Eval(SpeakerName)%>
Right now I am using the following code to get a ListView items value
Right now I am able to retrieve the network status using the following code..
Right now, I am using the following code to create a Shuffle extension: public
Right now I'm using the following: export CFLAGS=-O2-isysroot/Developer/SDKs/MacOSX10.5.sdk -arch i386 -I/sw/include/ export LDFLAGS=-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk,-L/sw/lib/ sudo
I've a basic URL validation in my appliction. Right now i'm using the following
I am new to CUDA. I am trying to parallelize the following code. Right
We are using a Java EE application and we are right now using Informix
Right now I am using sqlite within a ios application, and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.