Board index » delphi » How to sort Decending TListView columns.

How to sort Decending TListView columns.

Hi Everyone,

Does anyone know how to sort a TListView column (in vsReport view) in
"decending" order?  I am using the following to do an "Ascending" sort:

procedure TFLIForm.FileListViewColumnClick(Sender: TObject;
  Column: TListColumn);
begin
  ColumnToSort := Column.Index;
  (Sender as TCustomListView).AlphaSort;
end;

procedure TFLIForm.FileListViewCompare(Sender: TObject; Item1,
  Item2: TListItem; Data: Integer; var Compare: Integer);
var
  x: Integer;
begin
  if ColumnToSort = 0 then
    Compare := CompareText(Item1.Caption,Item2.Caption)
  else
    begin
    x := ColumnToSort - 1;
    Compare := CompareText(Item1.SubItems[x],Item2.SubItems[x]);
    end;
end;

Any ideas?

TIA,

Glenn

 

Re:How to sort Decending TListView columns.


Quote
In article <86ipb4$n...@bornews.borland.com>, Glenn Gothjelpsen wrote:
> Does anyone know how to sort a TListView column (in vsReport view) in
> "decending" order?  I am using the following to do an "Ascending" sort:

Either:

  Compare := -Compare;

or swap the order of the parameters passed to CompareText.

 Mike Orriss (TeamB)
 (Unless stated otherwise, my replies relate to Delphi 4.03/5.00)
 (Unsolicited e-mail replies will most likely be ignored)

Other Threads