我是 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。
组合框不显示序列号列表。
我该怎么办?
m_p ComboBox 变量名称表明这是一个成员指针引用。也许您想使用:
m_pComboBox->SetCurSel(0);
和
m_pComboBox->AddString(str);
?
也许你必须首先将
.getSerialNumber()
转换为字符串。