明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1567|回复: 0

停靠栏的问题,希望好心人帮帮忙看看,问题该怎么解决

[复制链接]
发表于 2006-8-13 12:32:00 | 显示全部楼层 |阅读模式

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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 23:14 , Processed in 0.161403 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表