CComboBox::InsertString

插入到组合框的列表框中。

int InsertString(
   int nIndex,
   LPCTSTR lpszString 
);

参数

  • nIndex
    包含从零开始的索引来在将接收该字符串的列表框的位置。 如果此参数是– 1,则字符串添加到列表的末尾。

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

返回值

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

备注

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

备注

此功能不是由Windows ComboBoxEx 控件支持。有关此控件的更多信息,请参见 Windows SDK的 ComboBoxEx控件

示例

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

要求

Header: afxwin.h

请参见

参考

CComboBox选件类

层次结构图

CComboBox::AddString

CComboBox::DeleteString

CComboBox::ResetContent

CB_INSERTSTRING