I think is preferable to change the format of the date to year/month/day:
07/10/2001 ---> 2001/10/07
that way the user can sort the listview by clicking on the column.
Daniel Weigel
Ciudad de la Costa
Uruguay
-----Mensaje original-----
De: Nigel Parker [mailto:Nigel.Parker@c...]
Enviado el: Martes, 20 de Noviembre de 2001 08:13 a.m.
Para: professional vb
Asunto: [pro_vb] Sorting A Listiview By date
Hi
I have the following code to sort a listview when the column header is
clicked:
Private Sub lvwOverview_ColumnClick(ByVal ColumnHeader As
MSComctlLib.ColumnHeader)
Dim intSortCol As Integer
' when a column header is clicked, the list view
' control is sorted by the sub items of that column
' set the sortkey to the index of the ColumnHeader - 1
intSortCol = ColumnHeader.Index - 1
If (lvwOverview.SortKey = intSortCol) Then
' if the list view sort key = ColumnHeader index value
' then subtract the sortOrder from 1, this will
' reverse the sort order
lvwOverview.SortOrder = 1 - lvwOverview.SortOrder
Else
lvwOverview.SortKey = intSortCol
lvwOverview.SortOrder = lvwAscending
End If
' now do the sorting
lvwOverview.Sorted = True
End Sub
Is there any way that I can get the column/listview to re-order itself
when the column contents are either a date or contains a date/time
combination?
for example, as the data is loaded it is in StartDate DESC order which is
fine
because the data is ordered and held in a recordset.
However after loading and when the StartDate column is clicked (to re-order)
the date
will look something like this...
(UK date format)
StartDate ASC
07/10/2001
12/09/2001
15/11/2001
etc...
I would appreciate any help or tips on how to achieve this.
Regards
Nigel
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com