Public Sub msSortListview(lsv As ListView, lncol As Integer, lnType As tColumnType)
' Receives the listview, the column on which the click
' is made and type of data contained in the column
Dim li As ListItem
If lnType <> gcnText Then
For Each li In lsv.ListItems
If lncol > 1 Then
li.Tag = li.SubItems(lncol - 1)
Else
li.Tag = li.Text
End If
Next
For Each li In lsv.ListItems
Select Case lnType
Case gcnNumber
If lncol > 1 Then
li.SubItems(lncol - 1) = Format(mfnValorNumerico(li.SubItems(lncol - 1)), "0000000000.00000")
Else
li.Text = Format(mfnValorNumerico(li.Text), "0000000000.00000")
End If
Case gcnDateTime
If lncol > 1 Then
li.SubItems(lncol - 1) = Format(CVDate(li.SubItems(lncol - 1)), "yyyy-mm-dd hh:mm:ss")
Else
li.Text = Format(CVDate(li.Text), "yyyy-mm-dd hh:mm:ss")
End If
Case gcnText
End Select
Next
End If
If lsv.SortKey = lncol - 1 Then
lsv.SortOrder = IIf(lsv.SortOrder = lvwAscending, lvwDescending, lvwAscending)
Else
lsv.SortOrder = lvwAscending
lsv.SortKey = lncol - 1
End If
lsv.Sorted = True
If lnType <> gcnText Then
For Each li In lsv.ListItems ' Restauramos los valores
If lncol > 1 Then
li.SubItems(lncol - 1) = li.Tag
Else
li.Text = li.Tag
End If
li.Tag = ""
Next
End If
End Sub