
Get items from Listview sorted with API:s in sorted order
Hi,
I have used API:s to sort a listview according to numeric values and not the
string values. (This is a common method described at several VB-sites like
www.mvps.org/vbnet).
My problem is that i need to retrieve thoose values, to print a report with
the contents of the listview, in the sorted order. You can't get the values
from the ListItems collection since the API-method only sort the items
visually (or something like that). So I tried to retrieve them through the
same API:s used to sort the items, but I still get them in the same order as
they were added to the ListView...
Anyone knows how to get the listitems in the sorted order?
' This is how I tried to get the ListItems values with API:s
' and it works, i just don't get them in the sorted order...
Public Function GetListviewItem(ByVal hWnd As Long, ByVal lngColumn As Long,
ByVal lngRow As Long) As String
Dim hIndex As Long
Dim r As Long
'Convert the input parameter to an index in the list view
objFind.flags = LVFI_PARAM
objFind.lParam = lngRow
hIndex = SendMessage(hWnd, LVM_FINDITEM, -1, objFind)
'Obtain the value of the specified list view item.
'The objItem.iSubItem member is set to the index
'of the column that is being retrieved.
objItem.mask = LVIF_TEXT
objItem.iSubItem = lngColumn
objItem.pszText = Space$(32)
objItem.cchTextMax = Len(objItem.pszText)
r = SendMessage(hWnd, LVM_GETITEMTEXT, hIndex, objItem)
If r > 0 Then
GetListviewItem = Left$(objItem.pszText, r)
End If
End Function
--
/Per
______________________________
Per Hultqvist, Hogia Ekonomi AB
MCP - Microsoft Certified Professional