How do I arrange files in a listbox by specific properties?

MMangano

New member
Joined
Feb 6, 2008
Messages
2
Programming Experience
Beginner
Hi, I currently need help in figuring out how to arrange files in a listbox by the specific properties such as Creation Date, or Name, or Last Modified Date Thank You.
 
You mean Listview? It doesn't make sense to sort data in a UI list where you can't see the data sorted on.
 
No, The program is to get two Directories and compare the files within them, then show the files in another listbox. I want to be able to compare the files by Date created and such, then put them in the 3rd Listbox by oldest or something like that. Thank You!
 
First of all you would define a class that implemented the IComparer(Of FileInfo) interface such that you could specify any property you wanted to compare by. You would then create an array or List of your FileInfo objects, bind it to a BindingSource and then bind that to your ListBox.

When ever you wanted to sort the data you'd create an instance of your class, set the property to compare by and then call the Sort method of the array or List, passing your IComparer as a parameter. That will sort the items in the desired order and you then call the ResetBindings method of the BindingSource to refresh the display.
 
Back
Top