Group Items in Delphi's TListView Control with Expandable and Collapsible Sections
The TListView Delphi control displays and manages a list of items, displayed in columns, vertically or horizontally, with small or large icons.
Windows XP, and later versions, support grouping items in a list view. With the grouping feature of the ListView control, related sets of items can be displayed in groups. Groups are separated on the screen by horizontal group headers that contain the group titles.
If you are using Delphi 2007, Delphi 7 or any other previous version, you can also have grouping functionality in the TListView control.
Read the full article to learn how to Mimick List View Item Grouping with Expandable and Collapsible Sections
Related:


Comments
The source download is incorrect. It’s for a thread signal demo.
@Vic: Ah
thanks for noticing. Fixed!
Very nice suff but unfortunately quit useless if you (still need to) support windows 2000.
@Marius: Why? The code works on any Delphi version, on any Windows. It just uses the Data property of a TListItem to mimic grouping with expand and collapse features.
This procedure is incorrect in D7:
procedure TForm1.ClearListViewGroups;
var
li : TListItem;
qng : TGroupItem;
begin
for li in lvGroups.Items do // exception is here
begin
if TObject(li.Data) is TGroupItem then
begin
qng := TGroupItem(li.Data);
FreeAndNil(qng);
end;
end;
lvGroups.Clear;
end;
Thanx
Is Marius right when he claims that this code is not compatible with W2K?
@Joar: No, the code is not dependant on the Windows version.
@Florent : Delphi 7 does not support “for in”. Use “for i…”: http://delphi.about.com/od/beginners/a/delphi_loops.htm
@Zarko: Thanks! Btw: thanks for the great work here at delphi.about.com!