TilalHusain
TilalHusain

Reputation: 1016

Populate Drop Down in MFC

I am trying populate a combo box in MFC application with no luck, I have tried all the methods available on internet but none seems to work for me, if I try to enter the values using data option in property windows like "value 1; value 2" only value 2 displays in combo box, if I try to add it using

comboxbox.AddString("value 1");

I get

left side of AddString must have class/union/struct.

I am using Visual Studio 2008.

Upvotes: 7

Views: 19300

Answers (2)

Jeeva
Jeeva

Reputation: 4663

Create a control variable for the combobox and call m_ctrlCombo.AddString(_T("My String"));

Another thing you need to do is open your dialog in resource editor select the combo box, click the arrow of the combobox and now you will see the combobox will be highlighted now drag it using your mouse downwards.

Upvotes: 0

Ajay
Ajay

Reputation: 18411

CComboBox* pComboBox = (CComboBox*)GetDlgItem(YOUR_COMBO_ID);

pComboBox->AddString( _T( "Value" ) ); 
pComboBox->AddString( _T( "Value" ) ); 

To know what _T means: Read this

Upvotes: 9

Related Questions