Hi
Here is the two ways to get/set comboboxes:
I set up a dialogbox with a combo ( IDC_COMBO) and use the ClassWizard to add two members:
one to type string m_StrCombo
one of type control m_Combo
The ClassWizard adds this in DoDataExchange
DDX_Control(pDX, IDC_COMBO, m_Combo);
DDX_CBString(pDX, IDC_COMBO, m_strCombo);
I populate the combo in OnInitDialog:
CString str;
for ( int n = 0; n < 10; n++)
{
str.Format( "%d", n);
m_Combo.AddString( str);
}
Here is the easy way to get and set:
to get the currently selected item:
UpdateData( TRUE);
AfxMessageBox( m_strCombo);
to set a new selection:
m_strCombo = "1"; // this set the second item
// item 0 is "0"
UpdateData( FALSE);
The 'hard' way:
to get the current selection
CString str;
int nItem = m_Combo.GetCurSel();
if ( nItem != CB_ERR)
{
m_Combo.GetLBText( nItem, str);
AfxMessageBox( str);
}
to set a new selection
m_Combo.SetCurSel( 2); // this set the third item
HTH
Thierry
EMail: Thierry.Marneffe@swing.be