我的排序代码是这样的
windowsxpform.XPTree.Header.SortColumn:=1;
windowsxpform.XPTree.Header.SortDirection:=sdDescending;
windowsxpform.XPTree.SortTree(1,sdDescending,false);组件的compare事件已经写好了,测试也是没问题的。
就是排序不行,一排序就是内存访问错误官方demo的排序是这样的
procedure TWindowsXPForm.XPTreeHeaderClick(Sender: TVTHeader; Column: TColumnIndex; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);begin
  if Button = mbLeft then
  begin
    with Sender, Treeview do
    begin
      if SortColumn > NoColumn then
        Columns[SortColumn].Options := Columns[SortColumn].Options + [coParentColor];      // Do not sort the last column, it contains nothing to sort.
      if Column = 2 then
        //SortColumn := NoColumn
      else
      begin
        if (SortColumn = NoColumn) or (SortColumn <> Column) then
        begin
          SortColumn := Column;
          SortDirection := sdAscending;
        end
        else
          if SortDirection = sdAscending then
            SortDirection := sdDescending
          else
            SortDirection := sdAscending;        Columns[SortColumn].Color := $F7F7F7;
        SortTree(sortcolumn, SortDirection, true);
      end;
    end;
  end;
end;把官方的demo的排序换成我那个也不行,郁闷,有人知道怎么回事么?谢