卫生间有窗户防水步骤:如何在LISTVIEW控件中添加己知路径的文件

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/13 15:37:31
假如我要添加完整路径为H:\accessmdb\dwg\部门1\车间11\泵\chroma.dwg的一个文件到listview控件中显示出来,如何实现呢??

在MFC中CListView是在CView和CListCtrl中继承的,而该类的列表功能主要从 CListCtrl 获得.
可以使用下列方式来获得 CListView 中的 CListCtrl 成员
CListCtrl& theCtrl = GetListCtrl();
然后可以在 theCtrl 中添加需要的列表项
下面的例子来自 MSDN 供参考
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);
}