比如要在第一列,第二列第四列各显示一个image及文本,
详细步骤。    第一列    第二列    第三列    第四列
    图 文本   图 文本   文本      图 文本    
    图 文本   图 文本   文本      图 文本    
    图 文本   图 文本   文本      图 文本    
    图 文本   图 文本   文本      图 文本    
    图 文本   图 文本   文本      图 文本    
    图 文本   图 文本   文本      图 文本    
    图 文本   图 文本   文本      图 文本    

解决方案 »

  1.   

    http://www.codeproject.com/listctrl/supergrid.asp
      

  2.   

    CListCtrl有一个extend style:LVS_EX_SUBITEMIMAGE,用SetExtendedStyle加上这个style后就可以在多个column设置image了.
      

  3.   

    CListCtrlParentContianer::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
    {
    NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
        
        *pResult = 0;    // If this is the beginning of the control's paint cycle, request
        // notifications for each item.    if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
            {
            *pResult = CDRF_NOTIFYITEMDRAW;
            }
        else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
            {
            // This is the pre-paint stage for an item.  We need to make another
            // request to be notified during the post-paint stage.        *pResult = CDRF_NOTIFYPOSTPAINT;
            }
        else if ( CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage )
            {
            // If this item is selected, re-draw the icon in its normal
            // color (not blended with the highlight color).
            LVITEM rItem;
            int    nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );        // Get the image index and state of this item.  Note that we need to
            // check the selected state manually.  The docs _say_ that the
            // item's state is in pLVCD->nmcd.uItemState, but during my testing
            // it was always equal to 0x0201, which doesn't make sense, since
            // the max CDIS_ constant in commctrl.h is 0x0100.        ZeroMemory ( &rItem, sizeof(LVITEM) );
            rItem.mask  = LVIF_IMAGE | LVIF_STATE;
            rItem.iItem = nItem;
            rItem.stateMask = LVIS_SELECTED;
            m_list.GetItem ( &rItem );        // If this item is selected, redraw the icon with its normal colors.        if ( rItem.state & LVIS_SELECTED )
                {
                CDC*  pDC = CDC::FromHandle ( pLVCD->nmcd.hdc );
                CRect rcIcon;            // Get the rect that holds the item's icon.
                m_list.GetItemRect ( nItem, &rcIcon, LVIR_ICON );            // Draw the icon.
                m_imglist.Draw ( pDC, rItem.iImage, rcIcon.TopLeft(),
                                 ILD_TRANSPARENT );            *pResult = CDRF_SKIPDEFAULT;
                }
            }
    }
      

  4.   

    TO: mickyf(小黑)
         设了LVS_EX_SUBITEMIMAGE后如何加image, 请详细点.TO:  okli(东方不BUG)
     
    CListCtrlParentContianer::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
    {
    NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
        
        *pResult = 0;
    ....
    }
    不懂。哪里来的,请解释一下,谢谢!
      

  5.   

    www.codeguru.com
    使用窗体和控件的信息交互过程,具体在msdn中有说明
      

  6.   

    设完之后当然就调用一下SetItem()了.
    假设你要设置第一行第二列为image
    则:
    LVITEM lvitem;
    lvitem.mask = LVIF_IMAGE; 
    lvitem.iItem = 0;
    lvitem.iSubItem = 1;
    lvitem.iImage = 0; //0是你的imagelist里面的第一个image
    VERIFY( m_wndList.SetItem( &lvitem ) );
      

  7.   

    To: mickyf(小黑)   这样还是只能有一列有image,其他各列都不能有啊!
      

  8.   

    lvitem.iSubItem可以随便设置嘛,从0到m_wndList.GetColumnCount() - 1,给个循环或者麻烦点一个个的写就可以了呀.LVS_EX_SUBITEMIMAGE的意思是任何列都可以设置Image.
    三少爷的剑倒不错...
      

  9.   

    To: mickyf(小黑)     妙,结账!