有代码更好,谢谢!

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2293/2293563.xml?temp=.5030634
      

  2.   

    Ctrl 和view..没大区别
            CListView::OnInitialUpdate(); CListCtrl & pList=GetListCtrl(); m_pSet=&GetDocument()->m_DataSet;
    if(m_pSet->IsOpen())
    m_pSet->Close();
    m_pSet->Open();
    for(short i=0;i<m_pSet->m_nFields;i++)
    {
    m_pSet->GetODBCFieldInfo(i,fieldInfo);
    pList.InsertColumn(i+1,fieldInfo.m_strName);
    }
      

  3.   

    _RecordsetPtr rsData;
    try{
    rsData.CreateInstance(__uuidof(Recordset));
    rsData->CursorLocation=adUseClient; 
    rsData->CursorType =adOpenStatic;
        rsData->Open(szSql,
      _variant_t((IDispatch*)theApp.m_AdoConnect,true),
            adOpenDynamic, 
        adLockBatchOptimistic, 
        adCmdText);
    }
    catch(...)
    {
    AfxMessageBox("更新列表视图出错");
    }
             while( !rsData->adoEOF)
    { long lIndex=m_pListWnd->m_listCtrl.GetItemCount();
                      m_listCtrl.InsertItem(lIndex,"",0);
    CString strTmp;
                      var=rsData->GetCollect("xxx");
    strTmp=var.bstrVal;
    m_listCtrl.SetItemText(lIndex,2,strTmp);
                      rsData->MoveNext();
    }