两个combo box关联

BOOL CTest_comboDlg::OnInitDialog()
{
 CDialog::OnInitDialog();

 // Add "About..." menu item to system menu.

 // Set the icon for this dialog.  The framework does this automatically
 //  when the application's main window is not a dialog
 SetIcon(m_hIcon, TRUE);   // Set big icon
 SetIcon(m_hIcon, FALSE);  // Set small icon
 
 // TODO: Add extra initialization here
 CComboBox* comboctrl1=(CComboBox*)GetDlgItem(IDC_COMBO1);
  comboctrl1->AddString("°²»Õ");
  comboctrl1->AddString("½­ËÕ");
  comboctrl1->AddString("ºþ±±");
  comboctrl1->AddString("ËÄ´¨");
     comboctrl1->SetCurSel(-1);
 CComboBox* comboctrl2=(CComboBox*)GetDlgItem(IDC_COMBO2);
      comboctrl2->SetCurSel(-1);
 return TRUE;  // return TRUE  unless you set the focus to a control
}

 

void CTest_comboDlg::OnSelchangeCombo1()
{
 // TODO: Add your control notification handler code here
 int n=-1;
 CComboBox* comboctrl1=(CComboBox*)GetDlgItem(IDC_COMBO1);
 int index=comboctrl1->GetCurSel();
 CString str_sel1;
 comboctrl1->GetLBText(index,str_sel1);
   if(!strcmp("°²»Õ",str_sel1))
       n=0;
       else if(!strcmp("½­ËÕ",str_sel1))
         n=1;
       else if(!strcmp("ºþ±±",str_sel1))
        n=2;
      else  if(!strcmp("ËÄ´¨",str_sel1))
         n=3;
 CComboBox* comboctrl2=(CComboBox*)GetDlgItem(IDC_COMBO2);
 switch(n)
   {
   case 0:
       comboctrl2->ResetContent();
     comboctrl2->AddString("ºÏ·Ê");
     comboctrl2->AddString("Îߺþ");
     comboctrl2->AddString("³²ºþ");
     comboctrl2->AddString("°ö²º");
     break;
   case 1:
    comboctrl2->ResetContent();
          comboctrl2->AddString("ÄϾ©");
    comboctrl2->AddString("ËÕÖÝ");
    comboctrl2->AddString("½­Òõ");
    comboctrl2->AddString("Ö£ÖÝ");
    comboctrl2->SetCurSel(-1);
    break;
   case 2:
    comboctrl2->ResetContent();
    comboctrl2->AddString("Î人");
    comboctrl2->AddString("Ò˲ý");
    comboctrl2->AddString("ÏÌÄþ");
    comboctrl2->AddString("ÉñÁú¼Ü");
    break;
  
   case 3:
        comboctrl2->ResetContent();
     comboctrl2->AddString("³É¶¼");
     comboctrl2->AddString("ÃàÑô");
     comboctrl2->AddString("¶¼½­Ñß");
     comboctrl2->AddString("è÷äü");
     break;
    
    default :
     comboctrl2->ResetContent();
      break;
 
 }
 
 
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值