MFC ComboBox

初始化:

 1 CComboBox* pC;
 2 pC = (CComboBox*)GetDlgItem(IDC_COMBO1);
 3 CString str[] = {("大于"),("大于等于"),("等于"),("小于"),("小于等于"),("不等于")};
 4 int d[6] = {1,5,4,2,6,8};
 5 
 6 for (int i = 0;i < 6; ++i)
 7 {
 8     int iAddString = pC->AddString(str[i]);
 9     pC->SetItemData(iAddString ,d[i]);
10 }

调用:

1 CComboBox* pBox;
2 pBox = (CComboBox*)GetDlgItem(IDC_COMBO1);
3 int x = pBox->GetItemData(pBox->GetCurSel());

 

上一篇:python3+pyQt5+QtDesignner实现窗口化猜数字游戏


下一篇:c# – ComboBox在更改DataSource后记住SelectedIndex