How to: Group Items in a Windows Forms ListView Control Using the Designer
The grouping feature of the ListView control enables you to 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:
The following procedure requires a Windows Application project with a form containing a ListView control. For information about setting up such a project, see How to: Create a Windows Forms application project and How to: Add Controls to Windows Forms.
To enable grouping, you must first create one or more ListViewGroup objects either in the designer or programmatically. Once a group has been defined, you can assign items to it.
To add or remove groups in the designer
In the Properties window, click the Ellipsis () button next to the Groups property.
The ListViewGroup Collection Editor appears.
To add a group, click the Add button. You can then set properties of the new group, such as the Header and HeaderAlignment properties. To remove a group, select it and click the Remove button.
To assign items to groups in the designer
In the Properties window, click the Ellipsis () button next to the Items property.
The ListViewItem Collection Editor appears.
To add a new item, click the Add button. You can then set properties of the new item, such as the Text and ImageIndex properties.
Select the Group property and choose a group from the drop-down list.
See also
.NET Desktop feedback