我在插入的时候调用了DeleteAllItems()然后再调用InsertItem()插入数据就不显示数据了。
把DeleteAllItems()注释掉之后就可以显示了。
用UpdateWindow()强制跟新也不行,不知道为什么?
怎么解决?

解决方案 »

  1.   

    CListCtrl::InsertItem
    int InsertItem( const LVITEM* pItem );int InsertItem( int nItem, LPCTSTR lpszItem );int InsertItem( int nItem, LPCTSTR lpszItem, int nImage );int InsertItem( UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam );Return ValueThe index of the new item if successful or -1 otherwise.ParameterspItemPointer to anLVITEM structure that specifies the item’s attributes, as described in the Platform SDK. nItemIndex of the item to be inserted.lpszItem Address of a string containing the item’s label, or LPSTR_TEXTCALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.nImageIndex of the item’s image, or I_IMAGECALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.nMaskThe nMask parameter specifies which item attributes passed as parameters are valid. It can be one or more of the mask values described inLVITEM structure in the Platform SDK. The valid values can be combined with the bitwise OR operator.nStateIndicates the item's state, state image, and overlay image. See the Platform SDK topics LVITEM for more information andList View Item States for a list of valid flags.nStateMaskIndicates which bits of the state member will be retrieved or modified. See LVITEM in the Platform SDK for more information.nImageIndex of the item’s image within the image list.lParamA 32-bit application-specific value associated with the item. If this parameter is specified, you must set the nMask attribute LVIF_PARAM.ResInserts an item into the list view control.CListCtrl Overview |  Class Members |  Hierarchy ChartSee Also   CListCtrl::DeleteItem, CListCtrl::DeleteAllItems
    CListCtrl::EnsureVisible
    BOOL EnsureVisible( int nItem, BOOL bPartialOK );Return ValueNonzero if successful; otherwise zero.ParametersnItemIndex of the list view item that is to be visible.bPartialOKSpecifies whether partial visibility is acceptable.ResCall this function to ensure that a list view item is at least partially visible. The list view control is scrolled if necessary. If the bPartialOK parameter is nonzero, no scrolling occurs if the item is partially visible.CListCtrl Overview |  Class Members |  Hierarchy ChartSee Also   CListCtrl::Scroll
    CListCtrl::Update
    BOOL Update( int nItem );Return ValueNonzero if successful; otherwise zero.ParametersnItemIndex of the item to be updated.ResCall this function to force the list view control to repaint the item specified by nItem. This function also arranges the list view control if it has the LVS_AUTOARRANGE style.CListCtrl Overview |  Class Members |  Hierarchy ChartSee Also   CListCtrl::DrawItem