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 ;)

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");
commented: Thank you. It worked +1

CComboBox does not have an items property. (CComboBox*)(GetDlgItem(IDC_COMBO1))->AddString("Text");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.