Export (0) Print
Expand All

CListBox::AddString

Adds a string to a list box.

int AddString(
   LPCTSTR lpszItem 
);

lpszItem

Points to the null-terminated string that is to be added.

The zero-based index to the string in the list box. The return value is LB_ERR if an error occurs; the return value is LB_ERRSPACE if insufficient space is available to store the new string.

If the list box was not created with the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted. If the list box was created with the LBS_SORT style but not the LBS_HASSTRINGS style, the framework sorts the list by one or more calls to the CompareItem member function.

Use InsertString to insert a string into a specific location within the list box.


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


Header: afxwin.h

Community Additions

ADD
Show:
© 2014 Microsoft