1

I am trying to create an mini total commander for my practice. At this moment , I want to add data from C:\D:\E:\ to the columns like in a standard total commander. Having at the moment 3 columns. Name, Type, Date Modified.

1
  • No idea what a total commander is... please explain better. Commented Jan 9, 2013 at 16:57

1 Answer 1

1

When you are adding items to list view, subitems are mapped to columns (by index). So, if you have three columns in ListView, then you should provide ListViewItem with three sub items:

string path = @"D:\";
var items = from file in new DirectoryInfo(path).EnumerateFiles()
            select new ListViewItem(new string[] {
                    Path.GetFileNameWithoutExtension(file.Name), // Name
                    Path.GetExtension(file.Name).Replace(".", ""), // Type
                    file.CreationTime.ToString()  // Date Modified               
                });

listView.Items.AddRange(items.ToArray());

Don't forget to set ListView view mode to View.Details - otherwise you will not see columns.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.