1
我需要遍历CComboBox中的项目(字符串)来检查哪个字符串是最长的。我如何获得列表中的每个项目?迭代通过MFC CComboBox的项目
我需要遍历CComboBox中的项目(字符串)来检查哪个字符串是最长的。我如何获得列表中的每个项目?迭代通过MFC 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;
}
我杀了你......和MSDN ...良好的答案,但麦克,在一个函数调用的爱情测试..呃。 int count = pmyComboBox-> GetCount(); – baash05 2009-01-06 01:51:46