若XXView继承的是CListCtrl类,那么直接调用函数CListCtrl &m_listctrl = GetCtrl();即可获取视图类中ListCtrl的指针,插入数据通过m_listctrl操作.
若是CListCtrl控件的话,则需要自己定义控件变量.

我看很多朋友是定义的lvcolumn结构体进行数据插入,因为这个功能较多,不过我觉得比较麻烦.

所以我喜欢用下面的方法:
int nIndex = m_listctrl.InsertColumn(m_listctrl.GetItemCount(), str);
m_listctrl.SetItemText(nIndex, 0, str1);
m_listctrl.SetItemText(nIndex, 1, str2);
m_listctrl.SetItemText(nIndex, 2, str3);
…比较方便,不过插入数据类型是有限制的.

另外将CListCtrl在代码中设置为Report形式需要在PreCreateWindow里加入:
cs.style |= LVS_REPORT | LVS_SINGLESEL;
cs.dwExStyle = LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2021-10-10
  • 2021-12-12
  • 2021-04-22
猜你喜欢
  • 2022-01-06
  • 2021-12-01
  • 2022-12-23
  • 2022-02-25
  • 2021-09-14
  • 2022-02-23
  • 2021-06-03
相关资源
相似解决方案