Std :: vector类型以在组合框中添加数据 [英] Std::vector type to add data in Combo Box

查看:128
本文介绍了Std :: vector类型以在组合框中添加数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的技术人员,

我是STL和MFC的新手,我需要一些线索来构建我的应用.

我有std :: vector< std :: string> xyz;并使用此变量,我需要在组合框中添加数据,以添加我已经使用过AddString()的数据,但是AddString()仅需要字符串.
因此,请帮我建议如何添加上述变量,以将数据添加到组合框,需要进行任何特定的转换..?

请提出建议.

谢谢.

问候,
技术人员.

Dear Techies,

I am a newbie to STL and MFC, I need bit clues for my app to build.

I have std::vector<std::string> xyz; and to using this variable I need to add data in a Combo Box, to add data I''ve used AddString(),but AddString() takes only string.
So pls help me suggesting how to add the above variable to add data to the combo box,any specific conversions required..?

Pls suggest.

Thanks.

Regards,
Techie.

推荐答案

尽管我从未听说过std:vectorxyz,但我建议您使用std :: vector< CString>.并使用std :: vector :: foreach将所有矢量内容添加到组合框.该链接可能对您有用!
though i never heard of std:vectorxyz, i could suggest you to use std::vector<CString> and using std::vector::foreach to add all vector content to combobox. this link might be useful for you!
http://www.google.co.in/url?sa=t&source=web&cd=2&ved=0CCMQFjAB&url=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms177203.aspx&ei=BS0UTvONC4mrsQLet9nUDw&usg=AFQjCNFew7ALVPTd42IzSjtorTWoYvq8SQ[^]


类似
的东西
Something like

for (vector<string>::iterator it = xyz.begin(); it != xyz.end(); ++it)
{
    m_combo.AddString(it->c_str());
}







or

for (size_t i = 0; i < xyz.size(); ++i)
{
    m_combo.AddString(xyz[i].c_str());
}



(不在我的头上)



(off the top of my head)


这篇关于Std :: vector类型以在组合框中添加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆