我的目的是,点击添加按钮,将内容保存在列表框(城市名, 结构体包含邮编和区号)
调用如图所示的函数,,将他和列表的一项绑定,然后选择列表框的某一项,,在文本框显示之前输入的内容,,但是结构体没有传过来,,这是为什么,求解答
你的m_CityCode有内容么?这个是编辑框输入的内容吧,看下你获的编辑框内容的代码是怎么写的呢
INT_PTR nRes;
CTipDlg tipDlg;
UpdateData(TRUE);
struct myData Data;
if (!IsValidate()) return;
nRes = tipDlg.DoModal();
int nIndex = my_ListBox.FindStringExact(-1, m_strCity);//查找
if (IDCANCEL == nRes) {
return;
}
else if (IDOK == nRes){
if (nIndex != LB_ERR) {
MessageBox(_T("该城市已添加!")); return;
}
MessageBox(_T("已填加新城市"));
}
Data.CityCode = m_CityCode;
Data.num = m_num;
nIndex = my_ListBox.AddString(m_strCity);//添加
my_ListBox.SetItemData(nIndex, (DWORD_PTR)(&Data));
我按添加按钮的内容,,,m_CityCode,m_num,m_City是三个编辑框的内容,,我想要在我点击列表框的一项时,将这三个内容全都显示在静态框里
列表框的程序
``int nIndex = my_ListBox.GetCurSel();
if (nIndex != LB_ERR) {
my_ListBox.GetText(nIndex, City);
Data = *((struct myData *)(my_ListBox.GetItemData(nIndex)));
// 使用当前列表项所关联的内容显示在控件上
code.Format(_T("%ld"), Data.CityCode);
num.Format(_T("%ld"), Data.num);
//UpdateData(FALSE);
dis = _T("城市:") + City + _T("邮政编码为:") + code + _T("区号为:") + num;
SetDlgItemText(IDCANCEL, dis);
}`
求解答。。。。。。。。。