1. Home
  2. Computing & Technology
  3. Delphi Programming
photo of Zarko Gajic
Zarko's Delphi Programming Blog

By Zarko Gajic, About.com Guide to Delphi Programming since 1998

Group Items in Delphi's TListView Control with Expandable and Collapsible Sections

Tuesday June 30, 2009
in TListView Ideas :: ListView item grouping 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

June 30, 2009 at 12:13 pm
(1) Vic says:

The source download is incorrect. It’s for a thread signal demo.

June 30, 2009 at 12:51 pm
(2) Zarko Gajic says:

@Vic: Ah :( thanks for noticing. Fixed!

July 1, 2009 at 4:14 am
(3) Marius says:

Very nice suff but unfortunately quit useless if you (still need to) support windows 2000.

July 1, 2009 at 6:31 am
(4) Zarko Gajic says:

@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.

September 4, 2009 at 6:15 pm
(5) Florent says:

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

October 1, 2009 at 8:46 am
(6) Joar says:

Is Marius right when he claims that this code is not compatible with W2K?

October 1, 2009 at 9:26 am
(7) Zarko Gajic says:

@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

October 1, 2009 at 9:40 am
(8) Joar says:

@Zarko: Thanks! Btw: thanks for the great work here at delphi.about.com!

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss
Community Forum
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.