ListView自己的排序是按Item的显示名称排序,你要实现点击每个Column都按该项排序,首先将SortType改为stData,然后在OnCompare事件中写排序的方法(有例子可以参考)。
点击Item,出现其编辑窗口,那就在OnClick事件中Show出一个窗口就行吧。

解决方案 »

  1.   

    在“delphi深度历险”有一个这样的例子,去cn.yahoo.com搜索一下吧
      

  2.   

    以下是我程序中的一段代码,实现按下Column时按指定的列升序和降序排列将将ListView的SortType属性改为stData
    var m_bSort : boolean;//用于控制升序及降序的转换
    //.................function CustomSortProc(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;
    var txt1,txt2 : string;
    begin
      if ParamSort <> 0 then begin
          txt1 := Item1.SubItems.Strings[ParamSort - 1];
          txt2 := Item2.SubItems.Strings[ParamSort - 1];
          if m_bSort then begin
             Result := CompareText(txt1,txt2);
          end else begin
             Result := -CompareText(txt1,txt2);
          end;
      end else begin
          if m_bSort then begin
             Result := CompareText(Item1.Caption,Item2.Caption);
          end else begin
             Result := -CompareText(Item1.Caption,Item2.Caption);
          end;
      end;
    end;procedure TForm1.ListView1ColumnClick(Sender: TObject;
      Column: TListColumn);
    begin
      ListView1.CustomSort(@CustomSortProc, Column.Index);
      m_bSort := not m_bSort;
    end;
      

  3.   

    Item的参数通过
    function CustomSortProc(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;的ParamSort参数传递。