Click here to Skip to main content
15,886,024 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.

[Edit: Made template argument visible.]
Posted
Updated 6-Jul-11 1:06am
v2
Comments
what is the vectorxyz type?
Sergey Alexandrovich Kryukov 6-Jul-11 2:15am    
It depends on what data you want to have in the combo box items, in what order.
--SA
ThatsAlok 6-Jul-11 5:39am    
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=3&ved=0CCoQFjAC&url=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fc4x1w65f(v%3Dvs.80).aspx&ei=BS0UTvONC4mrsQLet9nUDw&usg=AFQjCNFolckIANoq5vp-zT00gtjoGj9NCQ

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[^]
 
Share this answer
 
Comments
Richard MacCutchan 6-Jul-11 6:51am    
I suspect there is a space missing and it should read std::vector xyz;
Something like

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


or

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


(off the top of my head)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900