Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MFC ComboBox

Posted on 1999-01-20
10
Medium Priority
?
1,300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 60 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
 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

730 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