在ListView控件中有若干Columns[n]
现要实现
用鼠标点击一下Columns[n],显示的每条记录就依照Columns[n]排列
可以实现吗?

解决方案 »

  1.   

    转:
    像资源管理器那样对Subitem的内容进行排序。
    最好自己来控制排序,如下所示:function CustomSortProc( Item1, Item2 : TListItem; lParam : LongInt ) : Integer; stdcall;
    begin
       if lParam >= 0 then //lParam中保存的是SubItem的Index
       begin
          result := -CompareText(Item1.SubItems.Strings[lParam], 
                     Item1.SubItems.Strings[lParam] );
       end else
          result := 0;
    end;在ListView的ColumnClick事件响应方法中输入 
        CustomSort(@CustomSortProc, Column.Index );
      

  2.   

    我试了一下,Column的数量有3个,即0,1,2
    可是我按2的时候就会报错
    list index out bounds(2)
    这是怎么回事?
      

  3.   

    我也遇到了楼上的错误。
    “project project1.exe raised exception class EStringListError with message 'List index out of bounds(2)'.Process stopped.Use Step or Run to continue.”