试试这个,排序不理想自己完善下:function CustomSortProc(Item1, Item2: TListItem; lParam: LongInt): Integer; stdcall; begin if lParam >= 0 then //lParam中保存的是SubItem的Index begin result := -CompareText(Item2.SubItems.Strings[lParam], Item1.SubItems.Strings[lParam]); end else result := 0; endprocedure TSetRangeForm.ListView1ColumnClick(Sender: TObject; Column: TListColumn); begin TListView(Sender).CustomSort(@CustomSortProc, 0); end;
begin
if lParam >= 0 then //lParam中保存的是SubItem的Index
begin
result := -CompareText(Item2.SubItems.Strings[lParam], Item1.SubItems.Strings[lParam]);
end
else
result := 0;
endprocedure TSetRangeForm.ListView1ColumnClick(Sender: TObject;
Column: TListColumn);
begin
TListView(Sender).CustomSort(@CustomSortProc, 0);
end;