Link to home
Start Free TrialLog in
Avatar of dolphin King
dolphin King

asked on

Tviruailstringtree sort multi columns on header click

i am trying to sort each columns on Virtuailstringtree like this

var
Data1,Data2: PLUSTPAPULAE;
begin
Data1 := LISTSHOW.GetNodeData(Node1);
Data2 := LISTSHOW.GetNodeData(Node2);
if (Assigned(Data1)) And (Assigned(Data2)) then
begin

case Column of
0: Result := Result + CompareText(Data1.name, Data2.name);
1: Result := Result + CompareText(Data1.lvl, Data2.lvl);
end;

end;
end;

Open in new window




i have issue on header click it does not compare if i click on the second column . its only sort when i click on the first column i want to sort each column when i click on the column name

as example on click on column 0 sort column 0,, on click on column 1 sort column 1 and so on...

here is my header click code

procedure Tform1.LISTSHOWHeaderClick(Sender: TVTHeader;
  HitInfo: TVTHeaderHitInfo);
begin



    if HitInfo.Button = mbLeft then
  begin

    with Sender do
    begin
      if HitInfo.Column <> MainColumn then
        SortColumn := NoColumn
      else
      begin
        if SortColumn = NoColumn then
        begin

          SortColumn := HitInfo.Column;
          SortDirection := sdAscending;
        end
        else
          if SortDirection = sdAscending then
            SortDirection := sdDescending
          else
            SortDirection := sdAscending;
        Treeview.SortTree(SortColumn, SortDirection, False);
      end;
    end;
  end;

end;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pierre Cornelius
Pierre Cornelius
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial