CListView Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CListView Class.

Simplifies use of the list control and of CListCtrl, the class that encapsulates list-control functionality, with MFC's document-view architecture.

class CListView : public CCtrlView  

Public Constructors

NameDescription
CListView::CListViewConstructs a CListView object.

Public Methods

NameDescription
CListView::GetListCtrlReturns the list control associated with the view.

Protected Methods

NameDescription
CListView::RemoveImageListRemoves the specified image list from the list view.

For more information on this architecture, see the overview for the CView class and the cross-references cited there.

CObject

CCmdTarget

CWnd

CView

CCtrlView

CListView

Header: afxcview.h

Constructs a CListView object.

CListView();

Call this member function to get a reference to the list control associated with the view.

CListCtrl& GetListCtrl() const;  

Return Value

A reference to the list control associated with the view.

Example

void CMyListView::OnInitialUpdate()
{
   CListView::OnInitialUpdate();

   // this code only works for a report-mode list view
   ASSERT(GetStyle() & LVS_REPORT);

   CListCtrl& listCtrl = GetListCtrl();

   // Insert a column. This override is the most convenient.
   listCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT);

   // The other InsertColumn() override requires an initialized
   // LVCOLUMN structure.
   LVCOLUMN col;
   col.mask = LVCF_FMT | LVCF_TEXT;
   col.pszText = _T("Jersey Number");
   col.fmt = LVCFMT_LEFT;
   listCtrl.InsertColumn(1, &col);

   // Set reasonable widths for our columns
   listCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
   listCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
}

Removes the specified image list from the list view.

void RemoveImageList(int nImageList);

Parameters

nImageList
The zero-based index of the image to remove.

MFC Sample ROWLIST
CCtrlView Class
Hierarchy Chart
CCtrlView Class

Show: