[Lazarus] Strange Alphasort in ListView

Vojtěch Čihák vojtech.cihak at atlas.cz
Tue Apr 14 15:22:35 CEST 2015


I understand. Method Sort; is protected (as it is in Delphi).
 
You have probably no other choice than do
 
 ListView1.SortDirection:=sdDescending;
 ListView1.SortDirection:=sdAscending;
 
which works but it is unefficient, sorting is done twice.
 
I tried:
 ListView1.BeginUpdate;
 ListView1.SortDirection:=sdDescending;
 ListView1.EndUpdate;
 ListView1.SortDirection:=sdAscending;but it doesn't help, sorting is still done twice (at least on Qt).ListView has some flags to avoid sorting but those flags are private.V. 
 
______________________________________________________________
> Od: "Valdas Jankūnas" <zmuogs at gmail.com>
> Komu: Lazarus mailing list <lazarus at lists.lazarus.freepascal.org>
> Datum: 14.04.2015 15:02
> Předmět: Re: [Lazarus] Strange Alphasort in ListView
>
2015.04.14 15:34, Vojtěch Čihák rašė:
> No, it isn't a bug.
>
> In sources, you can see comment:
>
> function AlphaSort: Boolean; // always sorts column 0 in sdAscending order

Looked not in *primary* source (Google, Documentation) :)

>
> So if you want other sorting, you must set three sort-related properties:
>
> ListView1.SortColumn:=1;
> ListView1.SortDirection:=sdAscending;
> ListView1.SortType:=stText;
>
> It works, I just tested in Qt.

Why I came to AlphaSort: in my source ListView is cleared (columns stays 
same) and populated with new info. After that current column (say 
SortColumn=1) is no sorted (Autosort is TRUE; tried in Qt, Gtk2 and Win) 
so I must somehow to trigger sorting. But how?


-- 
   Valdas Jankūnas

--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus <http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150414/25218879/attachment-0003.html>


More information about the Lazarus mailing list