两个组合框调用一个数据库中的同一个表。控件1内容改变时,控件2内容相应改变,控件2内容改变时,控件1内容改变。
控件1:IDC_COMBO4 m_location
控件2:IDC_COMBO_ADDR m_locationaddr
void CHistoryDlg::OnSelchangeCombo4()//站点号 编辑框//
{
select_location = m_locationcombo.GetCurSel();//返回下拉列表框中当前选中的下标
m_locationcombo.GetLBText(select_location,strloc);/
//GetLBText( int nIndex, CString &rString ),把索引号为nIndex的数据放到rString变量中
m_locationaddr.SetCurSel(select_location);//实现数据的变动,站点号变动时地址跟随变动
}
void CHistoryDlg::OnSelchangeComboAddr()//地址
{
// TODO: 在此添加控件通知处理程序代码
select_locationaddr = m_locationaddr.GetCurSel();
m_locationaddr.GetLBText(select_locationaddr,strlocaddr);
m_locationcombo.SetCurSel(select_locationaddr);
}
缺陷:两个组合框中对应内容的标号 应一致