Help Auto Sort Listview SubItem in Form Load

erlleonardo

New member
Joined
Jan 25, 2012
Messages
4
Programming Experience
Beginner
Hello guys first of all good day is there any one can help me about Listview SubItem Sorting?

I have a listview1 then i want to sort automatically the subitem(9) when form is load and also adding new items
my Listview1 SubItem(9) is the date of my transaction so i need to orderly series from present to past transaction
i'm trying to use the Listview Property Setting Auto Sort but it will sort the first SubItem.

So please help me guys... Thanks and advance more power...
 
The ListView has a Sort method that you can call and you provide the implementation to compare items such that they are sorted in the way you want. You can call that whenever you like, e.g. after adding a new item. See the MSDN documentation for the method itself for an explanation and code example.

As for sorting when the form loads, surely it would make more sense to sort the data before adding it to the ListView in the first place. That will be much more efficient than loading the data first and then sorting the ListView. For instance, if the data is coming from a database then simply add an ORDER BY clause to your query.
 
Back
Top