Click here to Skip to main content
15,311,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm new with visual studio mfc c++, I want to create a combo box. I wrote:
CString str;
	for (int i = 0; i < 20; i++)
		str.Format(_T("item string %d"), i);

and then:

combo.GetLBText(combo.GetCurSel(), m_strTextCtrl);
	UpdateData(FALSE);// TODO: Add your control notification handler code here

but I don't know I must iniziatialize m_strTextCtrl

What I have tried:

I don't know how must initialize m_strTextCtrl
Updated 16-Sep-19 1:46am

1 solution

The destination variable should be a pointer to (wide) character buffer, or a reference to a CString object, as described in CComboBox::GetLBText | Microsoft Docs[^]. If this code is part of a dialog (and the UpdateData call suggests that it is), then the m_ prefix suggests that it should be a class variable, generated by the Class Wizard.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900