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);
}
我拷贝了这样一段代码,在程序运行的时候我为什么看不到列标题?也看不到记录
总之,什么也看不到!请问这是怎么回事?请高人指点一二!我的CMyListView继承的也是CListView呀!糊涂中着急中
{
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);
}
我拷贝了这样一段代码,在程序运行的时候我为什么看不到列标题?也看不到记录
总之,什么也看不到!请问这是怎么回事?请高人指点一二!我的CMyListView继承的也是CListView呀!糊涂中着急中
theCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT, 100);
theCtrl.InsertColumn(1, _T("Jersey Number"), LVCFMT_LEFT, 100);
其他的代码注释掉,试试
m_List.InsertColumn(1,"姓名");
m_List.InsertColumn(2,"图片"); m_List.SetColumnWidth(0,80);
m_List.SetColumnWidth(1,80);
m_List.SetColumnWidth(2,40);
你ListCtrl的属性,要设成,Report
ASSERT(GetStyle() & LVS_REPORT); 2。在CListCtrl& theCtrl = GetListCtrl();后面加入
LONG dwStyle = GetWindowLong( theCtrl.m_hWnd, GWL_STYLE ) ;
SetWindowLong( theCtrl.m_hWnd, GWL_STYLE, dwStyle | LVS_REPORT ) ;