我想把数据库中的数据显示出来其中用了“CListCtrl& ctrllist=(CListCtrl&)GetListCtrl();这条语句,可是编译的时候提示说D:\Code\Manage\ManageView.cpp(86) : error C2065: 'GetListCtrl' : undeclared identifier
在这个情况下要怎么处理它

解决方案 »

  1.   

    “identifier”: 未声明的标识符在可使用变量的类型前必须在声明中指定它。在可以使用函数前必须在声明或原型中指定该函数使用的参数。可能的原因 可能正在调用当前不受生成环境支持的 SDK 头文件中的函数。 
    省略必要的包含文件,尤其是在定义 VC_EXTRALEAN、WIN32_LEAN_AND_MEAN 或 WIN32_EXTRA_LEAN 时。这些符号从 windows.h 和 afxv_w32.h 中排除了一些头文件以加快编译。(在 windows.h 和 afxv_w32.h 中查找排除的头文件的最新说明。) 
    标识符名拼写错误。 
    标识符使用了错误的大小写字母。 
    字符串常数的后面缺少右引号。 
    字符串常数中的换行符没有继续符: 
    // C2065a.cpp
    #include <stdio.h>
    main() {
       printf("\n %s
          %s   // C2065, 's' : undeclared identifier
          %s",
          "this", "is", "it");
    }
    在若干行上拆分常数字符串时要特别小心。一种方法是更改格式字符串。仅由空白(空格、Tab 键、换行符)分隔的字符串被连接起来: #include <stdio.h>
    main() {
       printf("\n %s"
           " %s"
           " %s",
           "this", "is", "it");
    }
    不太可取的一种方法是在行尾使用反斜杠。每个连续行开头处的空格成为字符串的组成部分:    printf("\n %s\
           %s\
           %s",
           "this", "is", "it");
    命名空间范围不正确。例如,若要解析 ANSI C++ 标准库函数和运算符,则必须用 using 指令指定 std 命名空间。下面的示例未能编译,因为 using 指令被注释掉,并且在 std 命名空间中定义了 cout: 
    // C2065c.cpp
    #include <iostream>
    // using namespace std;
    void main()
    {
       cout << "Hello" << endl;   // C2065
    }
      

  2.   

    Call this member function to get a reference to the list control associated with the view.CListCtrl& GetListCtrl( ) const;
    Return Value
    A reference to the list control associated with the view.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);
    }
      

  3.   

    解决方法
    =========================
    在afxstd.h加入
    #include <afxcview.h>即可