Solved

MFC ComboBox

Posted on 1999-01-20
10
1,278 Views
Last Modified: 2013-11-20
How do I add strings to a combo box?  I tried Addstring method but it does not work.
thanks.
0
Comment
Question by:pipe
  • 4
  • 3
  • 2
  • +1
10 Comments
 

Expert Comment

by:ramrocket
ID: 1328063
cbBox.AddString("my string")
or
GetDlgItem(CB_ID)->AddString("my string")
0
 

Author Comment

by:pipe
ID: 1328064
Lemmie restat what I did. I plopped a combo box down on my app. I then used the app wizard to create a member variable from the ID.  I made a combo box ctl variable.  Then I tired to add a string to it. ie. myComboCtl->AddString("string"); with no results. I was sure to use the UpdateData or whatever mehtod afterwards.   Addstring does not work in my case.
 
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1328065
I tried it also, but didn';t get results also... It didn;t work here also... i'm actually a beginner in VC++, so I don't know the tricks to do it :))
0
 

Author Comment

by:pipe
ID: 1328066
why do ppl always tell me to do what i have already done. the prob was that if you dont drag yer combo box to be able to hold at least on string, it will get added but wont show up in the list box.
0
 
LVL 1

Accepted Solution

by:
The_Brain earned 30 total points
ID: 1328067
If you do it through Dialog editor, I am sure that you added...
CString m_ComboBoxStr  (type value);
CCombo m_ComboCtr (control value);

m_ComboCtr.AddString("The String");

But check on your Dialog editor, when you click on the drop button you will get another sizeable rectangle, resize it downwards.  (Also check if scrolling is on);

if this doesn't work post me the block of code that attempts to populate this combo.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:pipe
ID: 1328068
yes, thats what i did. take my points now
0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1328069
Does it work though?? it seems like you accepted it out of annoyance.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1328070
OK, here is what I did and it worked...

When you drop your ComboBox on the dialog, and you go to the properties of the Combo box... then you should choose the style of your combo box to be simple... You'll see a rectangle under the combobox which is just like a Listbox... You resize that so it's as big as you want it... then change the sie back to drop down, and you use your code to add strings...

((CComboBox *)GetDlgItem(IDC_MYCOMBO))->AddString("Whatever you want");

Now click on the button of the combo box and you will see the strings there.. Hope this helps..

-Viktor
--Ivanov
0
 

Author Comment

by:pipe
ID: 1328071
vc makes me bitchy some times. it didnt cross my mind that i needed to size the combo box list part until hours later.  the stuff was getting added, however the list was of no size and thats why it didnt show up. it does make sense that you need to size the list, but it just didnt pop into my head initially.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1328072
well, same here :) I didn't realize that till i tried to play with the properties of the combobox, and saw that the rectangle was too small...well glad to hear that you've finally got it to work :)

-Viktor
--Ivanov
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 177
move a line in eclipse 3 80
sum67 challenge 35 93
Annoying "thing" blocks my view 4 81
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now