This documentation is archived and is not being maintained.


Retrieves the number of items in a list box.

int GetCount( ) const;

The number of items in the list box, or LB_ERR if an error occurs.

The returned count is one greater than the index value of the last item (the index is zero-based).

// The pointer to my list box.
extern CListBox* pmyListBox;

// Add 10 items to the list box.
CString str;
for (int i=0;i < 10;i++)
   str.Format(_T("item %d"), i);
   pmyListBox->AddString( str );

// Verify that 10 items were added to the list box.
ASSERT(pmyListBox->GetCount() == 10);