Board index » kylix » Custom sort of TListView?

Custom sort of TListView?


2005-08-21 05:09:00 PM
kylix1
Can anyone suggest a way to implement a custom sort for the TListView
component? I'm using Kylix3 OE.
An example would be even nicer :-)
JohnK
 
 

Re:Custom sort of TListView?

John Kelly schrieb:
Quote
Can anyone suggest a way to implement a custom sort for the TListView
component? I'm using Kylix3 OE.

An example would be even nicer :-)

JohnK
Afaik there is no "built-in" way to custom-sort in TListView.
You can either add a column which contains the values you want to sort
by and then sort by this column, or (re-)fill the ListView already
sorted, i.e. sort externally maybe by using TList.Sort
 

Re:Custom sort of TListView?

theo wrote:
Quote
Afaik there is no "built-in" way to custom-sort in TListView.
You can either add a column which contains the values you want to sort
by and then sort by this column, or (re-)fill the ListView already
sorted, i.e. sort externally maybe by using TList.Sort
Thanks Theo, I actually want to sort on the imageindex and then a
secondary sort on the selected column as I do in my Delphi application
version. If I have to code this sort myself what would be a good
algorithm? (I was off that day in CS class. ;-) The list could run
into two or three thousand items and would get filled and sorted on startup.
 

{smallsort}

Re:Custom sort of TListView?

In article <4308dea9$ XXXX@XXXXX.COM >,
XXXX@XXXXX.COM (John Kelly) wrote:
Quote
If I have to code this sort myself what would be a good
algorithm? (I was off that day in CS class. ;-) The list could run
into two or three thousand items and would get filled and sorted on
startup.
Really too many items for a Windows listview to handle if it allocated
all the memory for them, at least in VCL, not used CLX. Much faster to
use OwnerData, store all the data yourself and then the sorting is much
easier. There is no real algorithm, sorting is a simple compare of two
items, if you are sorting more than one column, you combine them to sort.
Angus