就是自带的Tlistview
排序用ListViewColumnClick和ListViewCompare,看一下delphi自带的帮助!
图标用imaglist
参考下面:
procedure TMainForm.ListViewColumnClick(Sender: TObject;
Column: TListColumn);
begin
if nSortCol= Column.Index then
AscSort:= not AscSort
else
AscSort:= True;
nSortCol := Column.Index;
ListView.AlphaSort;
end;
procedure TMainForm.ListViewCompare(Sender: TObject; Item1,
Item2: TListItem; Data: Integer; var Compare: Integer);
CONST
(* ListView1 Column Headers *)
COLUMN_FILENAME = 0;
COLUMN_SIZE = 4;
COLUMN_ATTR = 3;
COLUMN_MODIFYDATE = 5;
var
size1,size2:integer;
Result: INTEGER;
begin
ListView.HeaderSortColumn:=nSortCol;
case nSortCol of
COLUMN_FILENAME:
Result := CompareText(Item1.Caption,Item2.Caption);
COLUMN_SIZE:
begin
size1 := StrToInt( Item1.SubItems.Strings [ nSortCol - 1 ] );
size2 := StrToInt( Item2.SubItems.Strings [ nSortCol - 1 ] );
Result := ( size1 - size2 );
end;
else
Result := CompareText(Item1.SubItems[nSortCol - 1],Item2.SubItems[nSortCol - 1]);
end;
IF AscSort THEN
Compare :=Result;
else
Compare := -Result;
end;