CListCtrl::GetGroupInfoByIndex

Retrieves information about a specified group in the current list-view control.

BOOL GetGroupInfoByIndex(
     int iIndex, 
     PLVGROUP pGroup
) const;

Parameters

Parameter

Description

[in] iIndex

Zero-based index of a group.

[out] pGroup

Pointer to an LVGROUP structure that receives information about the group specified by the iIndex parameter.

The caller is responsible for initializing the members of the LVGROUP structure. Set the cbSize member to the size of the structure, and the flags of the mask member to specify the information to retrieve.

Return Value

true if this method is successful; otherwise, false.

Remarks

This method sends the LVM_GETGROUPINFOBYINDEX message, which is described in the Windows SDK.

Requirements

Header: afxcmn.h

This control is supported in Windows Vista and later.

Additional requirements for this method are described in Build Requirements for Windows Vista Common Controls.

Example

The following code example defines a variable, m_listCtrl, that is used to access the current list-view control. This variable is used in the next example.

public:
    // Variable used to access the list control.
    CListCtrl m_listCtrl; 

The following code example demonstrates the GetGroupInfoByIndex method. In an earlier section of this code example we created a list-view control that displays two columns titled "ClientID" and "Grade" in a report view. The following code example retrieves information about the group whose index is 0, if such a group exists.

// GetGroupInfoByIndex 
    const int GROUP_HEADER_BUFFER_SIZE = 40;

// Initialize the structure 
    LVGROUP gInfo = {0};
    gInfo.cbSize = sizeof(LVGROUP);
    wchar_t wstrHeadGet[GROUP_HEADER_BUFFER_SIZE] = {0};
    gInfo.cchHeader = GROUP_HEADER_BUFFER_SIZE;
    gInfo.pszHeader = wstrHeadGet;
    gInfo.mask = (LVGF_ALIGN | LVGF_STATE | LVGF_HEADER | LVGF_GROUPID);
    gInfo.state = LVGS_NORMAL;
    gInfo.uAlign  = LVGA_HEADER_LEFT;

    BOOL bRet = m_listCtrl.GetGroupInfoByIndex( 0, &gInfo );
    if (bRet == TRUE) {
        CString strHeader = CString( gInfo.pszHeader );
        CString str;
        str.Format(_T("Header: '%s'"), strHeader);
        AfxMessageBox(str, MB_ICONINFORMATION);
    }
    else
    {
        AfxMessageBox(_T("No group information was retrieved."));
    }

See Also

Reference

CListCtrl Class

Hierarchy Chart

LVM_GETGROUPINFOBYINDEX

LVGROUP