Compartilhar via


CListBox::GetCount

Retrieves the number of items in a list box.

int GetCount( ) const;

Return Value

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

Remarks

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

Example

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

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

Requirements

Header: afxwin.h

See Also

Reference

CListBox Class

Hierarchy Chart

LB_GETCOUNT