Compartilhar via


CRecordView Class

A view that displays database records in controls.

class AFX_NOVTABLE CRecordView : public CFormView

Members

Protected Constructors

Name

Description

CRecordView::CRecordView

Constructs a CRecordView object.

Public Methods

Name

Description

CRecordView::IsOnFirstRecord

Returns nonzero if the current record is the first record in the associated recordset.

CRecordView::IsOnLastRecord

Returns nonzero if the current record is the last record in the associated recordset.

CRecordView::OnGetRecordset

Returns a pointer to an object of a class derived from CRecordset. ClassWizard overrides this function for you and creates the recordset if necessary.

CRecordView::OnMove

Protected Methods

Name

Description

CRecordView::OnMove

If the current record has changed, updates it on the data source, then moves to the specified record (next, previous, first, or last).

Remarks

The view is a form view directly connected to a CRecordset object. The view is created from a dialog template resource and displays the fields of the CRecordset object in the dialog template's controls. The CRecordView object uses dialog data exchange (DDX) and record field exchange (RFX) to automate the movement of data between the controls on the form and the fields of the recordset. CRecordView also supplies a default implementation for moving to the first, next, previous, or last record and an interface for updating the record currently on view.

Note

If you are working with the Data Access Objects (DAO) classes rather than the Open Database Connectivity (ODBC) classes, use class CDaoRecordView instead. For more information, see the article Overview: Database Programming.

The most common way to create your record view is with the Application Wizard. Tge Application Wizard creates both the record view class and its associated recordset class as part of your skeleton starter application. If you don't create the record view class with the Application Wizard, you can create it later with ClassWizard. If you simply need a single form, the Application Wizard approach is easier. ClassWizard lets you decide to use a record view later in the development process. Using ClassWizard to create a record view and a recordset separately and then connect them is the most flexible approach because it gives you more control in naming the recordset class and its .H/.CPP files. This approach also lets you have multiple record views on the same recordset class.

To make it easy for end-users to move from record to record in the record view, the Application Wizard creates menu (and optionally toolbar) resources for moving to the first, next, previous, or last record. If you create a record view class with ClassWizard, you need to create these resources yourself with the menu and bitmap editors.

For information about the default implementation for moving from record to record, see IsOnFirstRecord and IsOnLastRecord and the article Using a Record View.

CRecordView keeps track of the user's position in the recordset so that the record view can update the user interface. When the user moves to either end of the recordset, the record view disables user interface objects — such as menu items or toolbar buttons — for moving further in the same direction.

For more information about declaring and using your record view and recordset classes, see "Designing and Creating a Record View" in the article Record Views. For more information about how record views work and how to use them, see the article Using a Record View.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CView

CScrollView

CFormView

CRecordView

Requirements

Header: afxdb.h

See Also

Reference

CFormView Class

Hierarchy Chart

CRecordset Class

CFormView Class