如何将项目添加到组合框?

问题描述 投票:0回答:2

我是 MFC 的新手。 我不知道如何向组合框添加值。 我有一个向量类。

这是我的代码。

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 的类型是 CString。

组合框不显示序列号列表。

我该怎么办?

mfc combobox
2个回答
0
投票

m_p ComboBox 变量名称表明这是一个成员指针引用。也许您想使用:

m_pComboBox->SetCurSel(0);

m_pComboBox->AddString(str);


0
投票

也许你必须首先将

.getSerialNumber()
转换为字符串。

© www.soinside.com 2019 - 2024. All rights reserved.