The LVITEM::iGroupId
member expects a group ID but you are passing it a group index instead. That is why you cannot see the item - you are adding it to a non-existent group. You need to set item.iGroupId
to group.iGroupId
(ie 1
) instead.
Windows CListCtrl and groups
Question
I'm trying to create simple group in CListrCtrl with one element, but it doesn't show me anything:
EnableGroupView(TRUE);
LVGROUP group = { 0 };
group.cbSize = sizeof(LVGROUP);
group.iGroupId = 1;
group.state = LVGS_NORMAL;
group.mask = LVGF_GROUPID | LVGF_HEADER | LVGF_STATE | LVGF_ALIGN;
group.uAlign = LVGA_HEADER_LEFT;
int idx = InsertGroup(0, &group);
LVITEM item = {0};
item.mask = LVIF_TEXT | LVIF_IMAGE;// | LVIF_GROUPID;
item.iItem = 0;
item.iSubItem = 0;
item.pszText = L"aa";
item.cchTextMax = 3;
item.state = 0;
item.stateMask = LVIS_SELECTED;
item.iGroupId = idx;
InsertItem(&item);
BTW, I can see this item only if I don't enable group view mode. Am I doing something wrong?
PS: Windows 7 + MSVC 2010
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow