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.说明以加进去了。但就是看不到显示。。

}

解决方案 »

  1.   

    CTaskListView是后来加入去的是CListView派生的。
    原来是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);
      

  2.   

    你的 CTaskListView::PreCreateWindow(CREATESTRUCT& cs)函数里面的代码是什么?
      

  3.   

    CTaskListView::PreCreateWindow(CREATESTRUCT& cs)没有代码.
      

  4.   

    没有OverRide  CTaskListView::PreCreateWindow(CREATESTRUCT& cs)
      

  5.   

    代码是否如下?BOOL CTaskListView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs return CListView::PreCreateWindow(cs);
    }
      

  6.   

    刚才没有Override.现在是的。但,是还是不能显示。
    如查在你的程序里能显示。请您帮我个忙好吗?把你的代码zip一下email给我,我run一下看看效果。回为昨天直今一直在搞这个问题。总是不知道那里出了问题。查了很多资料,也不有结果。谢谢了。
      

  7.   

    刚才没有Override.现在是的。但还是不能显示。
    如果在你的程序里能显示。请您帮我个忙好吗?把你的代码zip一下email给我,我run一下看看效果。因为昨天至今一直在搞这个问题。总是不知道那里出了问题。查了很多资料,也不有结果。谢谢了。
      

  8.   

    给你发了邮件,粘了个zip文件.展开该文件,编译工程,运行结果是正确的.请查收.