有关它更详细的信息见这里:
http://blog.csdn.net/circlesquare/article/details/6929789
/获取list control列表里某一行的信息
POSITION ps;
int nIndex = -1;
ps= m_CtrlList.GetFirstSelectedItemPosition();
nIndex = m_CtrlList.GetNextSelectedItem(ps);
//TODO:添加多选的操作。
if(nIndex == -1)
{
//m_list.SetItemState(-1,LVNI_SELECTED,LVNI_SELECTED);
}
m_CtrlList.SetItemState(nIndex,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT);
CString str1;
//循环读取这一行里每一列的信息
for (i = 0 ; i < COLCOUNT; i++)
{
str1 = +m_CtrlList.GetItemText(nIndex,i);
}
///
/* 调整列表的行间距 begin */
CImageList Imagelist;
Imagelist.Create(1, 18, ILC_COLOR, 10, 10);
m_CtrlList.SetImageList(&Imagelist, LVSIL_SMALL);
/* 调整列表的行间距 end */
/* 初始化界面的列表框 begin*/
CString str[COLCOUNT] = {_T("注册号"),_T("企业名称"),_T("法人代表"), _T("住所")};
int nCompanyInfoListWidth[COLCOUNT] = {160, 300, 130 , 300};
m_CtrlList.SetExtendedStyle( LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES);
for ( int nCol = 0; nCol < COLCOUNT; nCol++)
{
m_CtrlList.InsertColumn(nCol, str[nCol], LVCFMT_LEFT, nCompanyInfoListWidth[nCol]);
}
/* 初始化界面的列表框 end*/
/* 测试数据 */
int nRow = m_CtrlList.InsertItem(0, _T("12345678"));//插入行
m_CtrlList.SetItemText(nRow, 1, _T("XXX公司"));//设置数据
m_CtrlList.SetItemText(nRow, 2, _T("胡XXXXX"));//设置数据
m_CtrlList.SetItemText(nRow, 3, _T("XXX市XXXX888号"));//设置数据
/* 测试数据 */
//不断插入数据并且刷屏的办法
int nIndex = m_lstMsg.GetItemCount();
m_lstMsg.InsertItem(nIndex, strItem);
// 只让显示最多100条记录
if (nIndex >= 100)
m_lstMsg.DeleteItem(0);
m_lstMsg.EnsureVisible(nIndex, true);