一篇对CListCtrl用法介绍较详细的文章:

http://www.cnblogs.com/wind-net/archive/2012/10/30/2745817.html


CListCtrl的最基本使用方法:

  1. 定义样式


DWORD dwStyle = m_listctrl.GetExtendedStyle();
dwStyle |= LVS_EX_FULLROWSELECT;//选中某行使整行高亮(只适用与report风格的listctrl)
dwStyle |= LVS_EX_GRIDLINES;//网格线(只适用与report风格的listctrl)
dwStyle |= LVS_REPORT;
m_listctrl.SetExtendedStyle(dwStyle); //设置扩展风格

2.插入行与列       

 //插入行
m_listctrl.InsertItem(0,_T("Row_0"));
m_listctrl.InsertItem(1,_T("Row_1"));
m_listctrl.InsertItem(2,_T("Row_2"));
//插入列
m_listctrl.InsertColumn(0,_T("Col_0"),LVCFMT_CENTER,50);
m_listctrl.InsertColumn(1,_T("Col_1"),LVCFMT_CENTER,100);
m_listctrl.InsertColumn(2,_T("Col_2"),LVCFMT_CENTER,50);

经过1,2步骤,一个3*3的列表框已被创建出来,接下来,可往里面添加内容

3.往[0,0],[1,0],[2,2]内分别填上A,B,C。

m_listctrl.SetItemText(0,0,_T("A"));
m_listctrl.SetItemText(1,0,_T("B"));
m_listctrl.SetItemText(2,2,_T("C"));

经过以上步骤,一个简单的列表控件就已经创建成功了。