[Lazarus] Can't make working sorting inTListView
Geoffray Levasseur-Brandin
jeff.levasseur at free.fr
Mon Jul 29 15:20:32 CEST 2013
Hello all !!
I've got a problem with the following code :
procedure TfMain.lvPackageListColumnClick(Sender: TObject; Column:
TListColumn);
begin
if Column.Index = FLastSortedColumn then
FAscending := not FAscending
else
FLastSortedColumn := Column.Index;
lvPackageList.SortColumn := Column.Index;
end;
procedure TfMain.lvPackageListCompare(Sender: TObject; Item1, Item2:
TListItem;
Data: Integer; var Compare: Integer);
begin
case Data of
0: Compare := AnsiCompareText(Item1.Caption, Item2.Caption); //pkgname
1: Compare := CompareVersion(Item1.SubItems[0], Item2.SubItems[0]);
//installed version
2: Compare := CompareVersion(Item1.SubItems[1], Item2.SubItems[1]); //last
version
3: Compare := CompareInstSize(Item1.Caption, Item2.Caption); //installed
size
4: Compare := CompareDefSize(Item1.Caption, Item2.Caption); //pkgsize
5: Compare := AnsiCompareText(Item1.SubItems[4], Item2.SubItems[4]);
//description
end;
if not FAscending then
Compare := -Compare;
end;
Whatever the column I'm clicking on it's always sorting the first column. I do
really not understand what's wrong. All the functions I've made giving Compare
its value returns correctly 1 if Itme1 > Item2, 0 if equal and -1 if Item1 <
Item2.
Thanks for any help.
--
Geoffray « Fatalerrors » Levasseur-Brandin
<jeff.levasseur at free.fr>
<geoffray.levasseur-brandin at ac-toulouse.fr>
http://www.geoffray-levasseur.org/
http://0.tuxfamily.org/
GNU/PG key : BF8BB8407CD26E89466CDA9BB1030FC59EF87775
Errare humanum est sed perseverare diabolicum aut cretinum.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130729/fb900202/attachment.sig>
More information about the Lazarus
mailing list