다음을 통해 공유


DDX_FieldText

The DDX_FieldText function manages the transfer of int, short, long, DWORD, CString, float, double, BOOL, or BYTE data between an edit box control and the field data members of a recordset.

void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   BYTE& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   int& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   UINT& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   long& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   DWORD& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   CString& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   float& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   double& value,
   CRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   short& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   BOOL& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   BYTE& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   long& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   DWORD& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   CString& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   float& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   double& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   COleDateTime& value,
   CDaoRecordset* pRecordset 
);
void AFXAPI DDX_FieldText(
   CDataExchange* pDX,
   int nIDC,
   COleCurrency& value,
   CDaoRecordset* pRecordset 
);

Parameters

  • pDX
    A pointer to a CDataExchange object. The framework supplies this object to establish the context of the data exchange, including its direction.

  • nIDC
    The ID of a control in the CRecordView or CDaoRecordView object.

  • value
    A reference to a field data member in the associated CRecordset or CDaoRecordset object. The data type of value depends on which of the overloaded versions of DDX_FieldText you use.

  • pRecordset
    A pointer to the CRecordset or CDaoRecordset object with which data is exchanged. This pointer enables DDX_FieldText to detect and set Null values.

Remarks

For CDaoRecordset objects, DDX_FieldText also manages transferring COleDateTime, and COleCurrency values. An empty edit box control indicates a Null value. On a transfer from the recordset to the control, if the recordset field is Null, the edit box is set to empty. On a transfer from control to recordset, if the control is empty, the recordset field is set to Null.

Use the versions with CRecordset parameters if you are working with the ODBC-based classes. Use the versions with CDaoRecordset parameters 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.

Example

The following DoDataExchange function for a CRecordView contains DDX_FieldText function calls for three data types: IDC_COURSELIST is a combo box; the other two controls are edit boxes. For DAO programming, the m_pSet parameter is a pointer to a CRecordset or CDaoRecordset.

void CMyDaoRecordView::DoDataExchange(CDataExchange* pDX)
{
   CDaoRecordView::DoDataExchange(pDX);
   DDX_FieldCBString(pDX, IDC_LASTNAME, m_pSet->m_LastName, m_pSet);
   DDX_FieldText(pDX, IDC_ID, m_pSet->m_EmployeeID, m_pSet);
   DDX_FieldText(pDX, IDC_AGE, m_pSet->m_Age, m_pSet);
}

Requirements

Header: afxdao.h

See Also

Concepts

MFC Macros and Globals

DDX_FieldRadio

DDX_FieldLBString

DDX_FieldLBStringExact

DDX_FieldCBString

DDX_FieldCBStringExact

DDX_FieldCBIndex

DDX_FieldLBIndex

DDX_FieldScroll