我需要遍历 CComboBox 中的项目(字符串)以检查哪个字符串最长。如何获取列表中的每个项目?
最佳答案
尝试 GetLBTextLen() 函数
这是一个 example from MSDN :
// 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;
}
关于visual-c++ - 遍历 MFC CComboBox 的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/380784/