How to: Group Items in a Windows Forms ListView Control
With the grouping feature of the ListView control, you can display related sets of items in groups. These groups are separated on the screen by horizontal group headers that contain the group titles. You can use ListView groups to make navigating large lists easier by grouping items alphabetically, by date, or by any other logical grouping. The following image shows some grouped items.
To enable grouping, you must first create one or more groups either in the designer or programmatically. After a group has been defined, you can assign ListView items to groups. You can also move items from one group to another programmatically.
Note
|
|---|
|
ListView groups are available only on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 when your application calls the ApplicationEnableVisualStyles method. On earlier operating systems, any code relating to groups has no effect and the groups will not appear. For more information, see ListViewGroups. |
To add groups
To remove groups
To assign items to groups or move items between groups
-
Set the ListViewItemGroup property of individual items.
Note