CListView.这样做....为什么不显示字符。CTaskListView是CListView派生来void CTaskListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl &lst=GetListCtrl();
DWORD dwStyle = WS_CHILD | LVS_REPORT | LVS_EDITLABELS|WS_VISIBLE;
::SetWindowLong(lst.m_hWnd, GWL_STYLE, dwStyle);
lst.InsertColumn(0,"时间",LVCFMT_LEFT,200,-1);
lst.InsertColumn(1,"说明",LVCFMT_LEFT,200,-1); CString strText;
int nColumnCount = lst.GetHeaderCtrl()->GetItemCount();
lst.DeleteAllItems();
// Insert 10 items in the list view control.
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i); // Insert the item, then select every other item.
lst.InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0); // Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
lst.SetItemText(i, j, strText);
}}
strText.Format("%d",lst.GetItemCount());
MessageBox(strText);//显示10.说明以加进去了。但就是看不到显示。。
}
{
CListView::OnInitialUpdate();
CListCtrl &lst=GetListCtrl();
DWORD dwStyle = WS_CHILD | LVS_REPORT | LVS_EDITLABELS|WS_VISIBLE;
::SetWindowLong(lst.m_hWnd, GWL_STYLE, dwStyle);
lst.InsertColumn(0,"时间",LVCFMT_LEFT,200,-1);
lst.InsertColumn(1,"说明",LVCFMT_LEFT,200,-1); CString strText;
int nColumnCount = lst.GetHeaderCtrl()->GetItemCount();
lst.DeleteAllItems();
// Insert 10 items in the list view control.
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i); // Insert the item, then select every other item.
lst.InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0); // Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
lst.SetItemText(i, j, strText);
}}
strText.Format("%d",lst.GetItemCount());
MessageBox(strText);//显示10.说明以加进去了。但就是看不到显示。。
}
原来是CView。是MFC生成向导生成的(SDI)。我把它删了。然后加CTaskListView.
最后在
APP.InitInstance()里改了
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTaskDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(TaskListView));//这里改成了TaskListView.
AddDocTemplate(pDocTemplate);
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs return CListView::PreCreateWindow(cs);
}
如查在你的程序里能显示。请您帮我个忙好吗?把你的代码zip一下email给我,我run一下看看效果。回为昨天直今一直在搞这个问题。总是不知道那里出了问题。查了很多资料,也不有结果。谢谢了。
如果在你的程序里能显示。请您帮我个忙好吗?把你的代码zip一下email给我,我run一下看看效果。因为昨天至今一直在搞这个问题。总是不知道那里出了问题。查了很多资料,也不有结果。谢谢了。