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.
-
No idea what a total commander is... please explain better.Hogan– Hogan2013-01-09 16:57:15 +00:00Commented Jan 9, 2013 at 16:57
Add a comment
|
1 Answer
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.