共用方式為


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