• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1156
  • Last Modified:

How to get values from MFC dialog box comboboxes and give to another class variable

How to get values from MFC dialog box
comboboxes and give to another class variable

How can i access the selected value

please specify how to set and get value from controls in mfc dialog boxes.
0
PBCHANDRAN
Asked:
PBCHANDRAN
1 Solution
 
HooKooDooKuCommented:
Try the following where IDC_CMB is what ever dialog ID value you've assigned the combo box control.
(Logic assumes it's being executed from within the dialog box, if not, change GetDlgItem() to something like MyDlg.GetDlgItem())
CString str; 
CComboBox* pCB = (CComboBox*) GetDlgItem( IDC_CMB );
int nCurSel = pCB->GetCurSel();
if( nCurSel != CB_ERR )
{
    pCB->GetLBText( nCurSel, str ); 
}
else
{
    pCB->GetWindowText( str );
}

Open in new window

0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now