首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >循环访问MFC CComboBox的项。

循环访问MFC CComboBox的项。
EN

Stack Overflow用户
提问于 2008-12-19 11:57:08
回答 1查看 5.2K关注 0票数 4

我需要遍历CComboBox中的项(字符串),以检查哪个字符串最长。如何获取列表中的每一项?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2008-12-19 12:00:48

尝试使用GetLBTextLen()函数

这是一个example from MSDN

代码语言:javascript
复制
// 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;
   }
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/380784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档