MFC如何实现通过一个按钮将两组单选框的内容复制到编辑框里

2025-04-04 11:18:31
推荐回答(1个)
回答(1):

CString strSex;
if ( IsDlgButtonChecked(IDC_BOY)   )    //  IDC_BOY为 boy    的ID
GetDlgItem(IDC_BOY)->GetWindowText(strSex);
else
GetDlgItem(IDC_BOY)->GetWindowText(strSex);
CString strAge;
if ( IsDlgButtonChecked(IDC_AGE20)   )      //  IDC_AGE20为 20     的ID
GetDlgItem(IDC_AGE20)->GetWindowText(strAge);
else if  ( IsDlgButtonChecked(IDC_AGE1520)   )      //  IDC_AGE20为  15--20   的ID
GetDlgItem(IDC_AGE1520)->GetWindowText(strAge);
else
GetDlgItem(IDC_AGE15)->GetWindowText(strAge);
  
SetDlgItemText(IDC_RESULT,strSex+strAge);  //IDC_RESULT 编辑框ID
//AfxMessageBox(strSex + strAge);

另外 ,想间隔开的话,自己加个空格符号什么的