rt
搜了半天没搜到原本想用
CListCtrl::GetColumn
CListCtrl::SetColumn但是LVCOLUMN.pszText这个没法赋值typedef struct _LVCOLUMN {
  UINT   mask;
  int    fmt;
  int    cx;
  LPTSTR pszText;
  int    cchTextMax;
  int    iSubItem;
#if (_WIN32_IE >= 0x0300)
  int    iImage;
  int    iOrder;
#endif 
#if (_WIN32_WINNT >= 0x0600)
  int    cxMin;
  int    cxDefault;
  int    cxIdeal;
#endif 
} LVCOLUMN, *LPLVCOLUMN;vc6
windows xp

解决方案 »

  1.   

    我是这么用的 LVCOLUMN col;
    col.mask = LVCF_TEXT;
    m_listDownload.GetColumn(0, &col);//-----------到这里就报错了
    // col.pszText = _T("2222222");
    // _tcscpy(col.pszText, _T("2222222"));
    m_listDownload.SetColumn(0, &col);
      

  2.   

    If the mask member specifies the LVCF_TEXT value, the pszText member must contain the address of the buffer that receives the item text and the cchTextMax member must specify the size of the buffer.
      

  3.   

    LVCOLUMN lvCom = {0};
    char szBuffer[256] = {0};
    strcpy(szBuffer,"test2");
    lvCom.mask = LVCF_TEXT;
    lvCom.cchTextMax = 256;
    lvCom.pszText = szBuffer;
    m_ListCtrl.SetColumn(0,&lvCom);
      

  4.   

    你这样用是可以的。
        LVCOLUMN col;
        col.mask = LVCF_TEXT;
        m_listDownload.GetColumn(0, &col);
        col.pszText = _T("2222222");
        m_listDownload.SetColumn(0, &col);在GetColumn的时候报错,估计是你的m_listDownload出问题了,比如被析构掉了,不如窗体还没有创建等。
      

  5.   

    LVCOLUMN m_vcolumn;
    CString strText = "name";
    m_vcolumn.mask = LVCF_TEXT;
    m_vcolumn.pszText =strText.GetBuffer(0);
    m_vcolumn.cchTextMax = strText.GetLength(); m_list.SetColumn(1,&m_vcolumn);上述代码改变第二列的名字为“name”
      

  6.   

    LVCOLUMN col;
    col.mask = LVCF_TEXT;
    m_listDownload.GetColumn(0, &col);//确认m_listDownload的m_hwnd句柄是否存在
    col.pszText = _T("2222222");
    m_listDownload.SetColumn(0, &col);
      

  7.   

    我是在菜单响应函数中,调用m_listDownload。
    按照常理,句柄应该是存在的,因为m_listDownload是我的成员变量,同时我又是在菜单响应函数中调用。不过从目前来看,也只可能是句柄不在了。
    哎!!!!!!!!!!!!
      

  8.   

    用CHeaderCtrl 
    下面的例子更换头的第0列名字  CHeaderCtrl *pHead = m_ListCtrl.GetHeaderCtrl();
      if(pHead && pHead->GetSafeHwnd())
      {
        TCHAR szBuf[129] = {0};
        HDITEM hdItem ={0};
        hdItem.mask = HDI_TEXT;
        hdItem.pszText = szBuf; //buff
        hdItem.cchTextMax = 128; //buff size
        pHead->GetItem(0, &hdItem); //get text    hdItem.pszText = _T("DDDDD");
        pHead->SetItem(0, &hdItem);
      }
      

  9.   

    BOOL SetColumn(
       int nCol,
       const LVCOLUMN* pColumn 
    );