1.添加默认的 Clistctrl 控件。关联变量 m_ctrList。
2. CImage m_ImageList;;
3.
m_Imagelist.Create(16,16,ILC_COLOR24|ILC_MASK,1,1);
m_Imagelist.SetBkColor(RGB(255,255,255));
m_Imagelist.Add(m_hIcon);
m_ctlList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_SUBITEMIMAGES);
m_ctlList.InsertColumn(0, _T("no1 "),LVCFMT_LEFT,80);
m_ctlList.InsertColumn(1, _T("no2 "),LVCFMT_LEFT,80);
m_ctlList.InsertColumn(2, _T("no3 "),LVCFMT_LEFT,80);
m_ctlList.InsertColumn(3, _T("no4 "),LVCFMT_LEFT,80);
m_ctlList.SetImageList(&m_Imagelist,LVSIL_SMALL);
m_ctlList.InsertItem(0, _T("abc "),0);//No1那列的图片不显示
m_ctlList.SetItem(0,1,LVIF_TEXT|LVIF_IMAGE,_T("123"),0,0,0,0);//在第一行第二列加入第1个图标
m_ctlList.SetItem(0,2,LVIF_TEXT|LVIF_IMAGE,_T("133"),0,0,0,0);//在第一行第三列加入第1个图标
m_ctlList.SetItem(0,3,LVIF_TEXT|LVIF_IMAGE,_T("133"),0,0,0,0);//在第一行第四列加入第1个图标
这样就能实现了,每一列都添加图标了!! 如下图: