Saturday, 31 August 2013

Sort listview column No. 2 (Sub Item 1) by date in C# when listview is filled with unsorted data

Sort listview column No. 2 (Sub Item 1) by date in C# when listview is
filled with unsorted data

I would like to fill a listView already with pre-sorted data and dunno
how. The data which is being added contains a "Name" and a "Date" Item
where the Name Item is the Main Item and the Date Item is the first
subitem. By default it is sorted by nothing or by the name only. I would
need the data being added already in such way, that it would be added
sorted by date (it is the second column and the subitem no. 1). I do not
need a sorting via Column Click. The sorting should be already from
beginning there without having to click on any columns in the listView
first.
So I have a List with a varying amount of items in the list. each
containing listviewitem in this List has a "Date"-Subitem. How would I
sort the List before I add it with the AddRange-Method and the
.toArray()-conversion to the listView? I use C# Exp. Net 2.0 on VS 2008
and I use a System Windows Forms listView with two columns, 1) Name, 2
Date. When the data is being added it shall be already sorted in date
order, newest date first.

No comments:

Post a Comment