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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:58:29+00:00 2026-05-25T22:58:29+00:00

I have a CheckedListBox in a WinForms app (3.5 runtime), and I am adding

  • 0

I have a CheckedListBox in a WinForms app (3.5 runtime), and I am adding a bunch of FileInfo objects to the Items ObjectCollection. The problem is that I don’t like what is displayed in the CheckedListBox (since the FileInfo was from a Directory.GetFiles() it just shows the FileInfo.Name of the file in the listbox).

Is there any easy way to change what is displayed in the CheckedListBox without having to create a seperate custom class/object.

I am basically doing

checkedListBox.Items.Add(fileInfo)

and the result is just the file name of the file.

Changing display member works but I can’t create something custom, only the existing properties in the FileInfo class.

I want to be able to display something like Name – FullName

Example (desired):
File1.txt – C:\Path\SubPath\File1.txt

  • 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-25T22:58:30+00:00Added an answer on May 25, 2026 at 10:58 pm

    Actually, it seems like it should be possible after all. The CheckedListBox has a FormattingEnabled property and a Format event inherited from ListBox which is called before each item is displayed. So something along these lines should work:

    myCheckedListBox.FormattingEnabled = true;
    myCheckedListBox.Format += (s, e) => { e.Value = string.Format("{0} - {1}", ((FileInfo)e.ListItem).Name, ((FileInfo)e.ListItem).FullName); };
    

    Haven’t tested it though. See also MSDN

    Old answer:

    I don’t think you can do it without creating a wrapper. Although 10 lines of code don’t seem all that bad to me:

    class FileInfoView
    {
        public FileInfo Info { get; private set; }
    
        public FileInfoView(FileInfo info)
        {
            Info = info;
        }
    
        public override string ToString()
        {
            // return whatever you want here
        }
    }
    

    The additional advantage to having a view model is that you can decorate it further for display purposes all the way you like.

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

Sidebar

Related Questions

I have a CheckedListBox. I would like to be able to select items when
Say that I have a CheckedListBox with items 1, 2, 3, 4, and 5
I have a CheckedListBox (WinForms) control (which inherits from ListBox; googling shows that the
im having a code a problem with the code.i have a checkedlistbox with 12
I have a checkedListBox (c#) and would like to have some of the boxes
I have a CheckedListBox, and I want to automatically tick one of the items
I have a DataBound CheckedListBox, I need to check some items on it. I
I have this code for casting CheckedListBox.Items to List<Item> : List<Item> items = ChkLsBxItemsToDraw.Items
I have a CheckedListBox which contains many items which can be checked or unchecked
I have a databinded checkedlistbox in one form and I would like to know

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.