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

  • SEARCH
  • Home
  • 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 8745279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:58:52+00:00 2026-06-13T11:58:52+00:00

I am beginner in c#. This is a small question. I want to add

  • 0

I am beginner in c#. This is a small question. I want to add Images to image list with image index.

  ilsLargeFlags  --> ImageList
  strFlagPath --> full file path
  strPetPath  --> only file name (gif image)

I tried the below code: (not working)

 ilsLargeFlags.Images.Add(Image.FromFile(strFlagPath));
 ilsLargeFlags.Images.SetKeyName(8, strPetPath);

what I am doing wrong in the above code?

There are already 8 images in the imageList. added by simple user interface( i dont know what it is said to be)

  • 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-13T11:58:53+00:00Added an answer on June 13, 2026 at 11:58 am

    You should better call ImageList.ImageCollection.Add(String, Image). In that case you could provide the key name in one step:

    ilsLargeFlags.Images.Add(strPetPath, Image.FromFile(strFlagPath));
    

    Update

    By using the ImageList and its internal ImageListCollection you won’t be able to set a specific numeric index (hence it does not support IndexOf() method. Instead you use some kind of self-defined string key. If you really need the current index of on image you should use the IndexOfKey() method after adding it to the list with the desired key:

    ilsLargeFlags.Images.Add(strPetPath, Image.FromFile(strFlagPath));
    var index = ilsLargeFlags.Images.IndexOfKey(strPetPath);
    

    Now it would be possible to change the key name by using the SetKeyName() method and the retrieved index, but this could lead to doubled key names if someone is going to remove images from the list and afterwards you would add another image. So better stick to some key names and get out the corresponding index at the moment you’ll need it by calling IndexOfKey().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a beginner and i need to ask a question.. I wrote this small
This is a beginner-best-practice question in perl. I'm new to this language. The question
This may be a beginner xml question, but how can I generate an xml
This is a beginner level question for asp.net MVC I have the following code
I believe this is a beginner's CSS question. I am utilizing the method described
I know this is silly question but as a beginner at xcode, and i
please forgive me if this is a noob question, but i'm a beginner at
Im a beginner programmer, and my question is: Which image format shall i use
This is going to be as beginner a question with getting started as you're
Sorry if this is a stupid noob question. I'm doing a very small project

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.