Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content


The DDX_FieldCBIndex function synchronizes the index of the selected item in the list box control of a combo box control in a record view and an int field data member of a recordset associated with the record view.

void AFXAPI DDX_FieldCBIndex(
   CDataExchange* pDX,
   int nIDC,
   int& index,
   CRecordset* pRecordset 
void AFXAPI DDX_FieldCBIndex(
   CDataExchange* pDX,
   int nIDC,
   int& index,
   CDaoRecordset* pRecordset 


A pointer to a CDataExchange object. The framework supplies this object to establish the context of the data exchange, including its direction.
The ID of a control in the CRecordView or CDaoRecordView object.
A reference to a field data member in the associated CRecordset or CDaoRecordset object.
A pointer to the CRecordset or CDaoRecordset object with which data is exchanged.


When moving data from the recordset to the control, this function sets the selection in the control based on the value specified in index. On a transfer from the recordset to the control, if the recordset field is Null, MFC sets the value of the index to 0. On a transfer from control to recordset, if the control is empty or if no item is selected, the recordset field is set to 0.

Use the first version if you are working with the ODBC-based classes. Use the second version if you are working with the DAO-based classes.

For more information about DDX, see Dialog Data Exchange and Validation. For examples and more information about DDX for CRecordView and CDaoRecordView fields, see the article Record Views.


See DDX_FieldText for a general DDX_Field example. The example would be similar for DDX_FieldCBIndex.

See Also

MFC Macros and Globals | DDX_FieldText | DDX_FieldRadio | DDX_FieldLBString | DDX_FieldLBStringExact | DDX_FieldCBStringExact | DDX_FieldLBIndex | DDX_FieldScroll | DDX_CBIndex

© 2015 Microsoft