Share via


CListBox::InsertString

intInsertString(intnIndex**,LPCTSTRlpszItem);**

Return Value

The zero-based index of the position at which the string was inserted. 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.

Parameters

nIndex

Specifies the zero-based index of the position to insert the string. If this parameter is –1, the string is added to the end of the list.

lpszItem

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

Remarks

Inserts a string into the list box. Unlike the AddString member function, InsertString does not cause a list with the LBS_SORT style to be sorted.

Example

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

// Insert items in between existing items.
CString str;
int n = pmyListBox->GetCount();
for (int i=0;i < n;i++)
{
   str.Format(_T("item string %c"), (char)('A'+i));
   pmyListBox->InsertString( 2*i, str );
}

CListBox OverviewClass MembersHierarchy Chart

See Also   CListBox::AddString,