停靠栏的问题,希望好心人帮帮忙看看,问题该怎么解决
<P>我在停靠栏上放了listcontrol控件,代码如下:要实现当停靠栏显示时,listcontrol中的数据也显示出来!extern _ConnectionPtr pConn;<BR>BOOL CAcDialogBar::Create (CFrameWnd *pParent, UINT nIDTemplate, UINT style, UINT nID) {<BR> if ( !CDialogBar::Create (pParent, nIDTemplate, style, nID) )<BR> return (FALSE) ;<BR> mSizeCurrent =m_sizeDefault ;<BR> CAcDialogBar m_MyBar;<BR> m_ctrlCoPeople.SubclassDlgItem(IDC_LS_COPeople,this); <BR> DWORD dwStyle = m_ctrlCoPeople.GetExtendedStyle();<BR> dwStyle |= LVS_EX_FULLROWSELECT dwStyle |= LVS_EX_GRIDLINES;<BR> m_ctrlCoPeople.SetExtendedStyle(dwStyle); //设置扩展风格<BR> m_ctrlCoPeople.InsertColumn(0,"协同用户");<BR> m_ctrlCoPeople.InsertColumn(1,"协同方式");<BR> m_ctrlCoPeople.InsertColumn(2,"用户IP");<BR> m_ctrlCoPeople.InsertColumn(3,"协同项目");<BR> m_ctrlCoPeople.InsertColumn(4,"协同模块"); <BR> m_ctrlCoPeople.SetColumnWidth(0,100);//设置列的宽度。<BR> m_ctrlCoPeople.SetColumnWidth(1,100);<BR> m_ctrlCoPeople.SetColumnWidth(2,100);<BR> m_ctrlCoPeople.SetColumnWidth(3,100);<BR> m_ctrlCoPeople.SetColumnWidth(4,100); <BR> CString vsql,vstrType,vstrName,vstrIp,vstrPid,vstrMid;<BR> _RecordsetPtr vst;<BR> _variant_t Holder;<BR> int i = 0;<BR> vst.CreateInstance(__uuidof(Recordset));<BR> vsql.Format("SELECT * FROM tempcoinfo");<BR> vst->Open(_variant_t(vsql),pConn.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);<BR> if(!vst->adoEOF)<BR> {<BR> m_ctrlCoPeople.DeleteAllItems();<BR> vst->MoveFirst();<BR> while (!vst->adoEOF)<BR> {<BR> LV_ITEM lvitem;<BR> lvitem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;<BR> lvitem.state = 0; <BR> lvitem.stateMask = 0; <BR> //char temp;<BR> <BR> lvitem.iItem = i;<BR> lvitem.iSubItem = 0;<BR> //lvitem.pszText =itoa(i, temp, 10); <BR> //m_ctrlCoPeople.InsertItem(&lvitem);<BR> Holder=vst->GetCollect("tempType");<BR> vstrType = Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR> Holder=vst->GetCollect("tempname");<BR> vstrName= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR> Holder=vst->GetCollect("tempip");<BR> vstrIp= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR> Holder=vst->GetCollect("coprojectid");<BR> vstrPid= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR> Holder=vst->GetCollect("comodeid");<BR> vstrMid= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder; <BR> <BR> lvitem.pszText =(LPSTR)LPCSTR(vstrName) ;<BR> m_ctrlCoPeople.InsertItem(&lvitem); <BR> m_ctrlCoPeople.SetItemText(i,1,(LPCTSTR)vstrType); m_ctrlCoPeople.SetItemText(i,2,(LPCTSTR)vstrIp);<BR> m_ctrlCoPeople.SetItemText(i,3,(LPCTSTR)vstrPid);<BR> m_ctrlCoPeople.SetItemText(i,4,(LPCTSTR)vstrMid); <BR> vst->MoveNext();<BR> i=i+1;<BR> }<BR> <BR> }<BR> vst->Close();<BR> delete vst; <BR> return (TRUE) ;<BR>}<BR>可是当运行时,所有m_ctrlCoPeople.SetItemText()语句只能在最后一条记录显示出数据来,其余的都不显示查询到的数据,请问该问题怎么解决,谢谢!!!</P>
页:
[1]