Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 2.15 KB

File metadata and controls

26 lines (20 loc) · 2.15 KB
title Record View Code Created by Application Wizard (MFC Data Access)
ms.date 11/04/2016
helpviewer_keywords
application wizards [C++], record view code
record views, refreshing controls
record views, application wizard code
ms.assetid 18fd4703-5939-491d-b759-985f767b951f

Record View Code Created by Application Wizard (MFC Data Access)

The MFC Application Wizard overrides the view's OnInitialUpdate and OnGetRecordset member functions. After the framework creates the frame window, document, and view, it calls OnInitialUpdate to initialize the view. OnInitialUpdate obtains a pointer to the recordset from the document. A call to the base class CView::OnInitialUpdate function opens the recordset. The following code shows this process for a CRecordView:

void CSectionForm::OnInitialUpdate()
{
   m_pSet = &GetDocument()->m_sectionSet;
   CRecordView::OnInitialUpdate();
}

When the recordset opens, it selects records. CRecordset::Open makes the first record the current record, and DDX moves data from the recordset's field data members to the corresponding form controls in the view. For more information about RFX, see Record Field Exchange (RFX). For more information about DDX, see Dialog Data Exchange and Validation. For information about the document/view creation process, see Using the Classes to Write Applications for Windows.

Note

You should give your end users the capability to refresh the record view controls from the recordset. Without this capability, if a user changes a control's value to an illegal value, the user can be permanently stuck on the current record. To refresh the controls, you call the CWnd member function UpdateData with a parameter of FALSE.

See also

Using a Record View