Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 13332, Sort a TListView Column

by Frank Hirka Email: Anonymous


Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 1.0  to 4.0 18 downloads
Copyright: No significant restrictions


Size: 0 bytes
Updated on Mon, 17 May 1999 00:00:00 GMT
Originally uploaded on Mon, 17 May 1999 00:00:00 GMT
Description
This Function sorts a selected Column in a TListView in Ascending order.

The sort can be on either the caption or one of the SubItems
fListItem1, fListItem2 : Items
fSortColumn : Column for sort (0 := Caption, 1 := SubItem 0; 2 := SubItem 1 etc.)

Function LVSortAscend(fListItem1, fListItem2: TListItem; fSortColumn: Integer): Integer;
stdcall;
begin
if fSortColumn = 0 then
Result := lstrcmp(Pchar(fListItem1.Caption), Pchar(fListItem2.Caption))
else
Result := lstrcmp(Pchar(fListItem1.SubItems[fSortColumn-1]), Pchar(fListItem2.SubItems[fSortColumn-1]));
end;


This Function sorts a selected Column in a TListView in Descending order.

The sort can be on either the caption or one of the SubItems
fListItem1, fListItem2 : Items
fSortColumn : Column for sort (0 := Caption, 1 := SubItem 0; 2 := SubItem 1 etc.)

Function LVSortDescend(fListItem1, fListItem2: TListItem; fSortColumn: Integer): Integer;
stdcall;
begin
if fSortColumn = 0 then
Result := lstrcmp(Pchar(fListItem2.Caption), Pchar(fListItem1.Caption))
else
Result := lstrcmp(Pchar(fListItem2.SubItems[fSortColumn-1]), Pchar(fListItem1.SubItems[fSortColumn-1]));
end;

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Server Response from: ETNACDC03