MFC列表框用AddString()后无显示内容!!! 10
函数功能是:我想在组合框选择一个类别后,列表框显示相应的个体:如在组合框选择”品牌"后在列表框里显示:相应的比如:“索尼”"摩托罗拉"“诺基亚”。代码如下:structP...
函数功能是:我想在组合框选择一个类别后,列表框显示相应的个体:如在组合框选择”品牌"后在列表框里显示:相应的比如:“索尼”"摩托罗拉"“诺基亚”。
代码如下:
struct Pinpai{
char * strType;
char * strname;
bool isselect;
};
struct CPU{
char * strcpu;
char * hz;
bool isselect;
};
struct RAM{
char * strram;
char * mb;
bool isselect;
};
struct FEN{
char * strfen;
char * strname;
bool isselect;
};
Pinpai P[]={"品牌","索尼",false,
"品牌","摩托罗拉",false,
"品牌","诺基亚",false
};
CPU C[]={"CPU主频","1024",false,
"CPU主频","800",false,
"CPU主频","600",false,
"CPU主频","312",false
};
RAM R[]={"内存","512",false,
"内存","256",false,
"内存","128",false,
"内存","64",false
};
FEN F[]={"分辨率","480*854",false,
"分辨率","360*640",false,
"分辨率","320*480",false,
"分辨率","240*320",false
};
我定义的结构体。下面是组合框函数:
void CShoujiDlg::OnEditchangeCombo1()
{
// TODO: Add your control notification handler code here
int Index=m_cmbType.GetCurSel();
m_cmbType.GetLBText(Index,m_strType);
m_lsname.ResetContent();
if(m_strType=="品牌"){
for(int i=0;i<3;i++){
m_lsname.AddString(P[i].strname);
}
}
else if(m_strType=="CPU主频"){
for(int i=0;i<4;i++){
m_lsname.AddString(C[i].hz);
}
}
else if(m_strType=="内存"){
for(int i=0;i<4;i++){
m_lsname.AddString(R[i].mb);
}
}
else if(m_strType=="分辨率"){
for(int i=0;i<4;i++){
m_lsname.AddString(F[i].strname);
}
}
} 展开
代码如下:
struct Pinpai{
char * strType;
char * strname;
bool isselect;
};
struct CPU{
char * strcpu;
char * hz;
bool isselect;
};
struct RAM{
char * strram;
char * mb;
bool isselect;
};
struct FEN{
char * strfen;
char * strname;
bool isselect;
};
Pinpai P[]={"品牌","索尼",false,
"品牌","摩托罗拉",false,
"品牌","诺基亚",false
};
CPU C[]={"CPU主频","1024",false,
"CPU主频","800",false,
"CPU主频","600",false,
"CPU主频","312",false
};
RAM R[]={"内存","512",false,
"内存","256",false,
"内存","128",false,
"内存","64",false
};
FEN F[]={"分辨率","480*854",false,
"分辨率","360*640",false,
"分辨率","320*480",false,
"分辨率","240*320",false
};
我定义的结构体。下面是组合框函数:
void CShoujiDlg::OnEditchangeCombo1()
{
// TODO: Add your control notification handler code here
int Index=m_cmbType.GetCurSel();
m_cmbType.GetLBText(Index,m_strType);
m_lsname.ResetContent();
if(m_strType=="品牌"){
for(int i=0;i<3;i++){
m_lsname.AddString(P[i].strname);
}
}
else if(m_strType=="CPU主频"){
for(int i=0;i<4;i++){
m_lsname.AddString(C[i].hz);
}
}
else if(m_strType=="内存"){
for(int i=0;i<4;i++){
m_lsname.AddString(R[i].mb);
}
}
else if(m_strType=="分辨率"){
for(int i=0;i<4;i++){
m_lsname.AddString(F[i].strname);
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询