• 向combobox控件中添加元素


    函数定义:
    bool FillComboBox(CComboBox* pc, CStringList& slValues, bool bOnlyUniqueValues = false);
    函数实现:
    bool FillComboBox(CComboBox* pc, CStringList& slValues, bool bOnlyUniqueValues)
    {
    	POSITION pos;
    	CString  s;
    
    	pc->ResetContent();
    	for (pos = slValues.GetHeadPosition(); pos != NULL;) {
    		s = slValues.GetNext(pos);
    		if (bOnlyUniqueValues) {
    			// String already in combobox
    			if (pc->FindStringExact(0, s) != CB_ERR) {
    				continue;
    			}
    		}
    		pc->AddString(s);
    	}
    
    	return true;
    }
    

    将字符串列表中的字符串加入combobox控件中,如:

    FillComboBox(&m_combobox, strList);

    其中m_combobox为combobox控件相关联的变量,strList为CStringList类型,里面保存的是要加入combobox控件中的字符串。

  • 相关阅读:
    爱信诺面试总结
    项目进展日志6
    项目进展日志5
    项目进展日志4
    项目进展日志3
    项目进展日志2
    项目阶段总结
    项目进展日志
    事物的ACID特性
    5.27作业
  • 原文地址:https://www.cnblogs.com/pengjun-shanghai/p/5133662.html
Copyright © 2020-2023  润新知