Solved

MFC ComboBox

Posted on 1999-01-20
10
1,273 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 109
VBA "SendKeys" Syntax for Multiple Keystrokes 7 98
mapBully challenge 6 89
Change to event 1 73
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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

21 Experts available now in Live!

Get 1:1 Help Now