GetLBText

GetLBText是Visual C++里CComboBox類中的成員函式。

基本介紹

  • 外文名:GetLBText
  • 學科:計算機
  • 套用:編程
  • 性質:名詞
簡介,參數說明,函式說明,示例,套用,

簡介

Gets a string from the list box of a combo box.
int GetLBText(int nIndex, LPTSTR lpszText) const;
void GetLBText(int nIndex, CString& rString ) const;
Return Value
The length (in bytes) of the string, excluding the terminating null character. If nIndexdoes not specify a valid index, the return value is CB_ERR.

參數說明

nIndex
Contains the zero-based index of the list-box string to be copied.
lpszText
Points to a buffer that is to receive the string. The buffer must have sufficient space for the string and a terminating null character.
rString
A reference to a CString.

函式說明

把索引號為nIndex的數據放到rString變數中. 與其對應的GetLBTextLen(int nIndex)函式就是得到索引號為nIndex中數據的長度。

示例

m_cbox.GetLBText (2,m_end); // GetLBText按鈕
UpdateData(0);
CString str; //GetLBTextLen按鈕
int i=m_cbox.GetLBTextLen (2);
str.Format ("%d",i);
m_end=str;
UpdateData(FALSE);
// The pointer to my combo box.extern CComboBox* pmyComboBox;
// Dump all of the items in the combo box.
#ifdef _DEBUG
CString str, str2;
int n;
for (int i=0;i < pmyComboBox->GetCount();i++)
{
n = pmyComboBox->GetLBTextLen( i );
pmyComboBox->GetLBText( i, str.GetBuffer(n) );
str.ReleaseBuffer();
str2.Format(_T("item %d: %s\r\n"), i, str.GetBuffer(0));
afxDump << str2;
}
#endif

套用

void CCMyComDlg::OnButton3()
{
CComboBox* combobox3 = (CComboBox*)GetDlgItem(IDC_COMBO3);
CString text;
combobox3->GetLBText(combobox3->GetCurSel(),text);
MessageBox(text,"提示");
}

相關詞條

熱門詞條

聯絡我們