Share via


CMFCListCtrl Class

The CMFCListCtrl class extends the functionality of CListCtrl Class class by supporting the advanced header control functionality of the CMFCHeaderCtrl Class.

class CMFCListCtrl : public CListCtrl

Members

Public Methods

Name

Description

CMFCListCtrl::EnableMarkSortedColumn

Enables the ability to mark a sorted column with a different background color.

CMFCListCtrl::EnableMultipleSort

Enables multiple sort mode.

CMFCListCtrl::GetHeaderCtrl

Returns a reference to the underlined header control.

CMFCListCtrl::IsMultipleSort

Checks if the list control is in multiple sort mode.

CMFCListCtrl::OnCompareItems

Called by the framework when it must compare two list control items.

CMFCListCtrl::OnGetCellBkColor

Called by the framework when it must determine the background color of an individual cell.

CMFCListCtrl::OnGetCellFont

Called by the framework when it must obtain the font for the cell being drawn.

CMFCListCtrl::OnGetCellTextColor

Called by the framework when it must determine the text color of an individual cell.

CMFCListCtrl::RemoveSortColumn

Removes a sort column from the list of sorted columns.

CMFCListCtrl::SetSortColumn

Sets the current sorted column and the sort order.

CMFCListCtrl::Sort

Sorts the list control.

Remarks

CMFCListCtrl offers two enhancements to CListCtrl Class class. First, it indicates that column sorting is an available option by automatically drawing a sort arrow on the header. Second, it supports data sorting on multiple columns at the same time.

Example

The following example demonstrates how to use various methods in the CMFCListCtrl class. The example shows how to create a list control, insert columns, insert items, set the text of an item, and set the font of the list control. This code snippet is part of the Visual Studio Demo sample.

    CMFCListCtrl m_wndWatch;


...


    // DWORD dwStyle 
    // CRect rectDummy
    m_wndWatch.Create(dwStyle, rectDummy, this, ID_LIST_1);
    m_wndWatch.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
    m_wndWatch.InsertColumn(0, _T("Variable"), LVCFMT_LEFT, 100);
    m_wndWatch.InsertColumn(1, _T("Value"), LVCFMT_LEFT, 100);

    m_wndWatch.InsertItem(0, _T("m_nCount"));
    m_wndWatch.SetItemText(0, 1, _T("100"));

    m_wndWatch.SetFont(&m_Font);

Inheritance Hierarchy

CObject

   CCmdTarget

      CWnd

         CListCtrl

            CMFCListCtrl

Requirements

Header: afxlistctrl.h

See Also

Reference

Hierarchy Chart

CListCtrl Class

Other Resources

MFC Classes