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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:59:44+00:00 2026-05-26T23:59:44+00:00

I have a CheckedListBox on a backup application I am writing. I want the

  • 0

I have a CheckedListBox on a backup application I am writing.
I want the user to pick the folders they want backing up i.e. desktop
I have my for loop working for each ticked item etc but I want the user to see the tick box labeled as “Desktop” rather than c:\users\username\desktop

Can someone inform me how to change the listbox label to something different than what is actually being returned to my for loop.

  • 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-26T23:59:45+00:00Added an answer on May 26, 2026 at 11:59 pm

    You should create a type that holds the full path and override ToString() to return what you want to display in the CheckedListBox. CheckedListBox.SelectedItems will then hold a list of your type.

        public void PopulateListBox()
        {
            _checkedListBox.Items.Add(new BackupDir(@"C:\foo\bar\desktop", "Desktop"));
        }
    
        public void IterateSelectedItems()
        {
            foreach(BackupDir backupDir in _checkedListBox.CheckedItems)
                Messagebox.Show(string.format("{0}({1}", backupDir.DisplayText, backupDir.Path));            
        }
    
        public class BackupDir
        {
            public string Path { get; private set; }
            public string DisplayText { get; private set; }
    
            public BackupDir(string path, string displayText)
            {
                Path = path;
                DisplayText = displayText;
            }
    
            public override string ToString()
            {
                return DisplayText;
            }
        }
    

    you could of course strip the folder name from the path if that is what you wanted to do for every list item and just have the path arg on the BackupDir class.

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

Sidebar

Related Questions

I have a CheckedListBox previously populated. I want to loop with a for each
I have CheckedListBox, now i want to put image from the ImageList next to
I have a CheckedListBox, and I want to automatically tick one of the items
I have a checkedlistbox and when i populate it i want to have an
I have a form containing a checkedlistbox, I want to be able to do
I have a checkedlistbox and I want to drag and drop only image extensions
I have a form with a CheckedListBox where the user can select multiple options
My requirement is, i have a checkedlistbox, and i want the selected item should
I have a CheckedListBox in my Windows forms application, but items can be added
I have a CheckedListBox where I want an event after an item is checked

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.