Click to See Complete Forum and Search --> : How to use combo box?
thryndel
May 7th, 1999, 12:30 PM
I want to create a vanilla drop down list box. I've been trying to use the CComboBox, but to no avail.
Whenever I run the program with it, it doesn't show the items, even if there are some. I'm using Visual C++ 6.0 w/ MFC. Any assistance would be appreciated.
Thanks in advance.
Eric Sebesta
Bootprint Entertainment
Safai Ma
May 7th, 1999, 12:44 PM
I think you need to select an item, otherwise it will be left unselected. m_CComboBox.SetCurSel(0) will select the first item in the box.
-Safai
Mike Harnad
May 7th, 1999, 03:19 PM
Be sure to use CComboBox::AddString() to add your strings. This is usually done in the OnInitDialog() event if you're doing this for a dialog. Also, be sure to call UpdateData(FALSE) at the end of OnInitDialog().
thryndel
May 7th, 1999, 05:14 PM
I tried both your and Mike's suggestions, but to no avail. Both suggestions did what they said they would: Mike's put the strings in the combo box, and your's did select the first string. But that's not my problem, even with both of those things implemented, when I click the drop-down button, it draws 2 or three lines of pixels below the combo box - not the "drop-down" effect we all know and love.
Any other suggestions? (and thanks to both of you for your guesses)
Eric Sebesta
Bootprint Entertainment
Safai Ma
May 7th, 1999, 11:00 PM
Now I know what your problem is. All you have to do is go to resource editor, click on your ComboBox control (the down arrow part). It should change between the 2 sizes, one for the 'regular' control size and the other is for the 'droped-down' control size. Adjust the 'droped-down' size to make the height bigger. That should solve your problem.
-Safai
babu
May 7th, 1999, 11:47 PM
Hi,
You need to set the Combobox style to 'drop-down-list'; You can do this either from the resource properties (styles tab) or in the code when you Create the combo using Create function (which takes styles as one of the parameter).
giri
Damir Cosic
May 11th, 1999, 10:52 AM
I had exactly same problem. Everything worked fine, I was able to add strings to the box and later to select them by arrow keys, but never got list displayed.
I solved it by deleting combo box in resource editor and using its member function Create() for creating box and setting its size and styles.
I am guessing that when you create combo box in resource editor it has some default size which is about the size of the box, without dropping list. I could't find way to increase the size from resource editor.
Damir
seems the problem is that the contents in the list are NOT displayed to you.
in OnInitDialog(), code as following :
CComboBox * c;
c=(CComboBox * )GetDlgItem(IDC_COMBO);
c->AddString(...);
While in resource editor, make sure
on the properties dialog, select the
"styles" tab, and on the "owner draw"
combo box, select "No".
Compile and you will find the strings
you added are displayed.
Rong
prabha vencat
May 25th, 1999, 02:24 AM
U can increase the size of the drop-down combo in the resource editor by exactly clicking on the down arrow(of the combo) and then resizing it.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.