胸怀天下 脚踏实地  
CListCtrl中加入数据
m_li.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EX_ONECLICKACTIVATE);
 m_li.InsertColumn(0,"姓名",LVCFMT_LEFT,80);
 m_li.InsertColumn(1,"性别",LVCFMT_LEFT,60);
 m_li.InsertColumn(2,"年龄",LVCFMT_LEFT,60);
 m_li.InsertItem(0,"王楠");                //要插入了Item后才能设置Item的Text
 m_li.InsertItem(1,"李平");
 int a=99;
 CString str;
 str.Format("%i",a);
 m_li.SetItemText(1,2,str);

单击CListCtrl后

POSITION   pos   =   m_li.GetFirstSelectedItemPosition(); 
 UINT i=m_li.GetNextSelectedItem(pos);
 char pBuf[11]="";
 CString s=m_li.GetItemText(i,2);

// itoa(i,pBuf,10);
 MessageBox(s);

09.9.23
Invalidate();//重绘界面

posted on 2009-09-11 21:13  icey  阅读(172)  评论(0编辑  收藏  举报