Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
MFC
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

CListCtrl::SetItemCountEx 

Sets the item count for a virtual list view control.


BOOL SetItemCountEx(
   int iCount,
   DWORD dwFlags = LVSICF_NOINVALIDATEALL 
);

Parameters

iCount

Number of items that the control will ultimately contain.

dwFlags

Specifies the behavior of the list view control after resetting the item count. This value can be a combination of the following:

  • LVSICF_NOINVALIDATEALL   The list view control will not repaint unless affected items are currently in view. This is the default value.

  • LVSICF_NOSCROLL   The list view control will not change the scroll position when the item count changes.

Nonzero if successful; otherwise zero.

This member function implements the behavior of the Win32 macro, ListView_SetItemCountEx, as described in the Platform SDK and should only be called for virtual list views.

// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;
CString str;

// Add 1024 items to the list view control.

// Force my virtual list view control to allocate 
// enough memory for my 1024 items.
pmyListCtrl->SetItemCountEx(1024, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL);

for (int i=0;i < 1024;i++)
{
   str.Format(TEXT("item %d"), i);
   pmyListCtrl->InsertItem(i, str);
}

Community Additions

ADD
Show:
© 2015 Microsoft