0

Hello. Can someone tell me how can i add string to combo box? i tried

GetDlgItem(IDC_COMBO1)->Items->Add("Text");

but it didn't worked. and everything that i could find on google didn't helped :( so i'm asking you pros ;)

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
1

Since this is MFC, see CComboBox::AddString() GetDlgItem() returns a CWnd * , meaning that you need a typecast to CComboBox * .

For example

CComboBox * pCombo = (CComboBox *) GetDlgItem(IDC_COMBO1);
pCombo->AddString("Text");
Votes + Comments
Thank you. It worked
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.