Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 1.75 KB

list-control-and-list-view.md

File metadata and controls

33 lines (21 loc) · 1.75 KB
description title ms.date helpviewer_keywords ms.assetid
Learn more about: List Control and List View
List Control and List View
11/04/2016
CListView class [MFC], and CListCtrl
views [MFC], list and list control
CListCtrl class [MFC], and CListView
list views [MFC]
list controls [MFC], List view
7aee1c48-b158-4399-be0b-be366993665e

List Control and List View

For convenience, MFC encapsulates the list control in two ways. You can use list controls:

  • Directly, by embedding a CListCtrl object in a dialog class.

  • Indirectly, by using class CListView.

CListView makes it easy to integrate a list control with the MFC document/view architecture, encapsulating the control much as CEditView encapsulates an edit control: the control fills the entire surface area of an MFC view. (The view is the control, cast to CListView.)

A CListView object inherits from CCtrlView and its base classes and adds a member function to retrieve the underlying list control. Use view members to work with the view as a view. Use the GetListCtrl member function to gain access to the list control's member functions. Use these members to:

  • Add, delete, or manipulate "items" in the list.

  • Set or get list control attributes.

To obtain a reference to the CListCtrl underlying a CListView, call GetListCtrl from your list view class:

[!code-cppNVC_MFCListView#4]

This topic describes both ways to use the list control.

See also

Using CListCtrl
Controls