2015.04.14 16:22, Vojtěch Čihák rašė:
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.


Thanks for mentioning protected Sort procedure. So I come to "dirty" solution:

 - create helper class:

type
  THack = class(TListView)
  public
     procedure Trigger_sort;
  end;

 - implement "Trigger_sort":

procedure THack.Trigger_sort;
begin
    Sort;
end;

 - now when to trigger sort with current settings is needed then execute:

THack(ListView1).Trigger_sort;


 Works for me (at least in Qt (Linux) and Win (Windows7)).



--
  Valdas Jankūnas

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to