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 6554039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:39:11+00:00 2026-05-25T12:39:11+00:00

I’m creating an window form UI consist of something like file browser (a ComboBox

  • 0

I’m creating an window form UI consist of something like file browser (a ComboBox and a ListView with image in the first column of each item), view of ListView I used is Detail, I’ve add images to the SmallImageList, already test the images are not null and set image index for each item but the images still not shown.

this is my code

        main_fileView.View = View.Details;
        string[] files;
        if (main_dirComboBox.Text != "")
        {
            string parent = main_dirComboBox.Text;
            if (System.IO.Directory.Exists(parent))
            {
                files = System.IO.Directory.GetFiles(parent);
                if (files != null)
                {
                    main_fileView.Items.Clear();
                    ImageList img_list = new ImageList();
                    int n = 0;


                    ImageList small_img_list = new ImageList();
                    ImageList large_img_list = new ImageList();

                    for (int i = 0; i < files.Length; i++)
                    {
                        string file_name = files[i].Substring(files[i].LastIndexOf('\\') + 1, files[i].Length - (files[i].LastIndexOf('\\') + 1));
                        string file_type = file_name.Substring(file_name.LastIndexOf('.'), file_name.Length - file_name.LastIndexOf('.'));
                        //get icon image from system
                        Icon smallicon = Icons.IconFromExtension(file_type, Icons.SystemIconSize.Small);
                        Icon largelicon = Icons.IconFromExtension(file_type, Icons.SystemIconSize.Large);
                        small_img_list.Images.Add(smallicon);
                        large_img_list.Images.Add(largelicon);

                    }

                    main_fileView.SmallImageList = small_img_list;
                    main_fileView.LargeImageList = large_img_list;

                    foreach (string file in files)
                    {

                        string file_name = file.Substring(file.LastIndexOf('\\')+1,file.Length-(file.LastIndexOf('\\')+1));
                        System.IO.FileInfo fileInfo = new System.IO.FileInfo(file);
                        string file_size = fileInfo.Length/1000+" kB";
                        string file_datemodified = fileInfo.LastWriteTime.ToString();
                        string file_createDate = fileInfo.CreationTime.ToString();

                        string[] item_ = { file_name, file_size, file_datemodified, file_createDate };

                        ListViewItem item = new ListViewItem(item_,n);
                        n++;
                        main_fileView.Items.Add(item);

                    }

                }
            }
        }

i’ve try replace

ListViewItem item = new ListViewItem(item_,n);

with

ListViewItem item = new ListViewItem(file_name, n);
                        item.SubItems.Add(file_size);
                        item.SubItems.Add(file_datemodified);
                        item.SubItems.Add(file_createDate);

but the result is still the same, there are blank spaces in front of each text in first column, but no image shown.

LAST EDITED

Finally I’ve got it, it’s my fault, the problem is not in this path of code, in other path of code there’s creating new ImageList which I’ve forget to comment it out before test, this code work properly, THANKS everyone for the answer.

ps. I can’t answer my own question within 8 hours cause of too little reputation

  • 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-05-25T12:39:11+00:00Added an answer on May 25, 2026 at 12:39 pm

    Considering that you show in ListView a details of a file selected in ComboBox, you use Details view. In other words you see the grid on UI.

    In this case you have to specify a special column for the row and push desired image in that cell.

    You can have a look here for more complex solution:

    ListView with Image on SubItems

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

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.