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 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.
ListView groups are available only on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 when your application calls the Application.EnableVisualStyles method. On earlier operating systems, any code relating to groups has no effect and the groups will not appear. For more information, see ListView.Groups.
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.
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 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.
Select the Group property and choose a group from the drop-down list.