Solved

MFC ComboBox

Posted on 1999-01-20
10
1,288 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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
 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
Best tools for Backup and restore of Wordpress site 6 57
Problem to open Excel file 15 178
"Black Box" Testing of Control System Software 2 70
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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