Click to See Complete Forum and Search --> : [VC++6.0] A Problem About Create ComboBox


HelloNet
April 26th, 1999, 09:05 PM
Hi,
I bulid a dialog box and add a combo box (m_try) by resource editor. And add this code in dialog's OnInitDialog():
m_try.AddString("Hello");
But the string "Hello" can't appear in the listbox.
Now I change the way to add this combo box: I type "CComboBox m_try" by myself in dialog class amd use m_try.Create() to create this combo box.
Now m_try.AddString("Hello") works well.
What's difference between the tow way? Thanks!

tchung
April 26th, 1999, 11:03 PM
maybe,
I wonder,
when you made a member-variable, m_try, for combo-box in Class-Wizard,
you set the category with 'Value'
Convert it to 'Control'


by nfuox

Bob Clarke
April 26th, 1999, 11:34 PM
In addition to tchung's reply, be sure you call m_try.SetCurSel(0) to set the current selection to the string you added.

HelloNet
April 29th, 1999, 04:26 AM
Thanks for Bob and tchung's answers! Now I can see the string which add by AddString() in the edit box of CComboBox.
But the string can't appear in the list box of CComboBox. The m_try's category is Control now,
and the ComboBox's type is drop-down.
The InitStorage() is also useless. Do you have any idea for this probelm? Thanks!

tchung
April 29th, 1999, 06:33 AM
Enlarge your combo-box More to down-side!


by nfuox

HelloNet
April 29th, 1999, 09:51 PM
If I create a ComboBox in dialog by myself, I can use m_try.Create() to fix the size of drop-down side. But while a ComboBox is alreay a member of the dialog, I needn't(can't) use Create() to create it. What method can I use to change the size of a ComboBox? Thanks!

sally
April 29th, 1999, 10:06 PM
in resourec editor, click on the combobox's arrow on the right of the combobox, then you can adjust the drop...

Sally

Sally
April 29th, 1999, 10:06 PM
in resourec editor, click on the combobox's arrow on the right of the combobox, then you can adjust the drop...

Sally

HelloNet
April 29th, 1999, 10:45 PM
Thanks! This method works well.

tchung
April 30th, 1999, 06:50 AM
When you create a CComboBox, you can adjust the Size of combo-box with some parameters.


m_try.Create(CBS_AUTOHSCROLL,CRect(10,10,150,150),this,101010);
m_try.ShowWindow(SW_SHOW);
m_try.AddString("Korea");
m_try.AddString("USA");
:
m_try.SetCurSel(0);





Sorry, But I did my best!


by nfuox