Example void CMyListView::OnInitialUpdate() { CListView::OnInitialUpdate(); // this code only works for a report-mode list view ASSERT(GetStyle() & LVS_REPORT); // Gain a reference to the list control itself CListCtrl& theCtrl = GetListCtrl(); // Insert a column. This override is the most convenient. theCtrl.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; theCtrl.InsertColumn(1, &col); // Set reasonable widths for our columns theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER); theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER); }获得listctrl指针后,使用deleteallitems();
void CMyListView::OnInitialUpdate()
{
CListView::OnInitialUpdate(); // this code only works for a report-mode list view
ASSERT(GetStyle() & LVS_REPORT); // Gain a reference to the list control itself
CListCtrl& theCtrl = GetListCtrl(); // Insert a column. This override is the most convenient.
theCtrl.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;
theCtrl.InsertColumn(1, &col); // Set reasonable widths for our columns
theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
}获得listctrl指针后,使用deleteallitems();
{
YourView.GetListCtrl.DeleteColumn(0);
}