Compartilhar via


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.

Syntax

class CListView : public CCtrlView  

Members

Public Constructors

Name Description
CListView::CListView Constructs a CListView object.

Public Methods

Name Description
CListView::GetListCtrl Returns the list control associated with the view.

Protected Methods

Name Description
CListView::RemoveImageList Removes the specified image list from the list view.

Remarks

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

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CView

CCtrlView

CListView

Requirements

Header: afxcview.h

CListView::CListView

Constructs a CListView object.

CListView();

CListView::GetListCtrl

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);
}

CListView::RemoveImageList

Removes the specified image list from the list view.

void RemoveImageList(int nImageList);

Parameters

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

See Also

MFC Sample ROWLIST
CCtrlView Class
Hierarchy Chart
CCtrlView Class