CComboBox::GetLBText

从组合框的列表框中获取字符串。

int GetLBText(
   int nIndex,
   LPTSTR lpszText 
) const;
void GetLBText(
   int nIndex,
   CString& rString 
) const;

参数

  • nIndex
    包含要复制的列表框中字符串的从零开始的索引。

  • lpszText
    指向是接收该字符串的缓冲区。 缓冲区必须有该字符串和一个终止null字符足够的空间。

  • rString
    CString 的引用。

返回值

长度(以字节为单位)的字符串,不包括终止null字符。 如果 nIndex 不指定一个有效的索引,则返回值是 CB_ERR

备注

该成员函数的第二个窗体包含项目的文本加载一 CString 对象。

示例

// Dump all of the items in the combo box.
CString str1, str2;
int n;
for (int i = 0; i < m_pComboBox->GetCount(); i++)
{
   n = m_pComboBox->GetLBTextLen(i);
   m_pComboBox->GetLBText(i, str1.GetBuffer(n));
   str1.ReleaseBuffer();

   str2.Format(_T("item %d: %s\r\n"), i, str1.GetBuffer(0));
   AFXDUMP(str2);
}

要求

Header: afxwin.h

请参见

参考

CComboBox选件类

层次结构图

CComboBox::GetLBTextLen

CB_GETLBTEXT