MFC单选按钮的使用

1.初始化选项,并给初始值:

//初始化单选按钮,并给初始值
((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("a");
((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("b");
((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("c");
((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("d");
((CComboBox*)GetDlgItem(IDC_COMBO1))->SetCurSel(2);

 

2.读去选择的值

//单选按钮
void CDialogDlg::OnButton4()
{
    // TODO: Add your control notification handler code here
    int index;
    index=((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();//获取光标的位置
    ((CComboBox*)GetDlgItem(IDC_COMBO1))->GetLBText(index,m_combo);
    MessageBox(m_combo);
}

你可能感兴趣的:(mfc)