Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this article
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
Name | Description |
---|---|
CListView::CListView | Constructs a CListView object. |
Name | Description |
---|---|
CListView::GetListCtrl | Returns the list control associated with the view. |
Name | Description |
---|---|
CListView::RemoveImageList | Removes 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.
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;
A reference to the list control associated with the view.
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);
nImageList
The zero-based index of the image to remove.
MFC Sample ROWLIST
CCtrlView Class
Hierarchy Chart
CCtrlView Class