【问题标题】:Iterate through the items of an MFC CComboBox遍历 MFC CComboBox 的项目
【发布时间】:2008-12-19 11:57:08
【问题描述】:

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

【问题讨论】:

    标签: visual-c++ mfc


    【解决方案1】:

    试试 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;
       }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多