This documentation is archived and is not being maintained.

CComboBox::GetCount 

Call this member function to retrieve the number of items in the list-box portion of a combo box.


int GetCount( ) const;

The number of items. The returned count is one greater than the index value of the last item (the index is zero-based). It is CB_ERR if an error occurs.

// The pointer to my combo box.
extern CComboBox* pmyComboBox;

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

// Verify the 10 items were added to the combo box.
ASSERT(pmyComboBox->GetCount() == 10);
Show: