How to Use Groups in a List-View
This topic describes how to create an instance of a group and add it to a list-view control. Grouping allows a user to arrange lists into groups of items that are visually divided on the page, using a horizontal divider and a group title.
- Windows User Interface Programming
To use groups in a list-view control, ensure that the control includes the LVS_ALIGNTOP window style.
When you add an item to the list, you assign it to a group by setting the iGroupId member of the item's LVITEM structure to the value of the iGroupId member of the groups's LVGROUP structure. An item that is not assigned to a group does not appear in the list when group view is enabled. To enable or disable group view, use the ListView_EnableGroupView macro.
The following example shows how to create a group with a header and add it to a list-view control.
LVGROUP group; group.cbSize = sizeof(LVGROUP); group.mask = LVGF_HEADER | LVGF_GROUPID; group.pszHeader = TEXT("Dogs"); group.iGroupId = 1; ListView_InsertGroup(hWndListView, -1, &group);