How to add item to a combobox?

断了今生、忘了曾经 提交于 2019-12-14 03:26:51

问题


I am a newbie to MFC. I don't know how to add values to a combobox. I have a vector class.

This is my code.

CellPhone cp;
vector<CellPhone> cellPhoneList;
cellPhoneList = cp.loadCellPhone();

m_pComboBox.SetCurSel(0);

for(unsigned int i=0; i<cellPhoneList.size(); i++)
{

  CString str = cellPhoneList[i].getSerialNumber();
  m_pComboBox.AddString(str);

}

serialNumber's type is CString.

combobox does not show serialNumber list.

how can I do?


回答1:


The m_p ComboBox variable name suggests that this is a member pointer reference. Perhaps you meant to use:

m_pComboBox->SetCurSel(0);

and

m_pComboBox->AddString(str);

?




回答2:


Maybe you have to convert your .getSerialNumber() to a string in first place.



来源:https://stackoverflow.com/questions/8925549/how-to-add-item-to-a-combobox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!