CComboBox::GetLBText

更新 : 2007 年 11 月

コンボ ボックスのリスト ボックスから文字列を取得します。

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

パラメータ

  • nIndex
    リスト ボックス内のコピーする文字列を 0 から始まるインデックスで指定します。

  • lpszText
    文字列を受け取るバッファへのポインタ。NULL 文字で終わる文字列を格納できるサイズのバッファを指定してください。

  • rString
    CString への参照。

戻り値

文字列の終端を示す NULL 文字を除いた文字列の長さ (バイト数) を返します。nIndex に無効なインデックスを指定した場合は、CB_ERR を返します。

解説

このメンバ関数の 2 番目の形式は、項目のテキストを 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);
}

必要条件

ヘッダー : afxwin.h

参照

参照

CComboBox クラス

階層図

CComboBox::GetLBTextLen

CB_GETLBTEXT

その他の技術情報

CComboBox のメンバ