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