Solved

MFC ComboBox

Posted on 1999-01-20
10
1,298 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
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

623 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