【发布时间】:2008-12-19 11:57:08
【问题描述】:
我需要遍历 CComboBox 中的项目(字符串)以检查哪个字符串最长。如何获取列表中的每一项?
【问题讨论】:
标签: visual-c++ mfc
我需要遍历 CComboBox 中的项目(字符串)以检查哪个字符串最长。如何获取列表中的每一项?
【问题讨论】:
标签: visual-c++ mfc
试试 GetLBTextLen() 函数
// Dump all of the items in the combo box.
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;
}
【讨论】: