CListBox::InsertString

插入到列表框中。

int InsertString(
   int nIndex,
   LPCTSTR lpszItem 
);

参数

  • nIndex
    指定该位置的从零开始的索引插入该字符串。 如果此参数是– 1,则字符串添加到列表的末尾。

  • lpszItem
    指向要插入的Null终止的字符串。

返回值

该字符串被插入位置的从零开始的索引。 如果发生错误,则返回值是 LB_ERR ;,如果没有足够的空间可用存储新字符串,则返回值是 LB_ERRSPACE

备注

不同 AddString 成员函数,InsertString 不会与 LBS_SORT 样式的列表排序。

示例

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

要求

Header: afxwin.h

请参见

参考

CListBox选件类

层次结构图

CListBox::AddString

LB_INSERTSTRING