CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2015
    Posts
    7

    How to add second column to a listBox component?

    For the moment I can only get the subfolders name of C:\Backup folder to the first column of the listBoxComputer.
    Have do I get also the last written date of subfolders to the second column of the listBoxComputer?

    Code:
    private string rootDir = @"C:\Backup";        
    
    private void FormView_Load(object sender, EventArgs e)        {                       
       List<string> ls = Directory.GetDirectories(rootDir).Select(Path.GetFileName).ToList();            
        ls.Sort((a, b) => -1 * a.CompareTo(b));        
        listBoxComputer.Sorted = false;            
        listBoxComputer.DataSource = ls;            
        listBoxUser.SelectedIndex =-1;           
    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to add second column to a listBox component?

    You are using the wrong control as the list box only has 1 one column. You will need to use a listview control instead. The listview control allows for multiple columns. https://docs.microsoft.com/en-us/dot...ramework-4.7.2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured