Get items from Listview sorted with API:s in sorted order 
Author Message
 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



Mon, 28 Jul 2003 20:53:46 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Sort order - Edit Filter Sort or Quick Sort

2. Listview - Changing sort order

3. ListView Sort order Question

4. Determing sort order in a ListView.

5. Listview sort Order

6. Sort Order arrows in ListView ColumnHeaders?

7. Listview sort-order

8. New altering ListView sort order problem

9. Can't sort Outlook Personal Folder using Items.Sort

10. Items.Sort NOT Sorting????

11. Sorting numbers in Descending Order using ORDER BY

12. Sorting numbers in Descending Order using ORDER BY

 

 
Powered by phpBB® Forum Software