我需要遍历CComboBox中的项(字符串),以检查哪个字符串最长。如何获取列表中的每一项?
发布于 2008-12-19 12:00:48
尝试使用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;
}https://stackoverflow.com/questions/380784
复制相似问题