<< Return to Main Index

< Return to Class Index

CGXBrowserGrid::OnAddedNewRecord

virtual void OnAddedNewRecord();?

Remarks

Called from Update when a new record has been added to the datasource.

The default implementation does not perform any functionality.

Some specific data sources need to do a Requery, as for example ODBC record sets. This can sometimes be very slow, and you may consider overriding this method for ODBC data sources and fine-tune it to the specific need of the ODBC driver.

Note:

Do not call SetCurrentCell from within OnAddedNewRecord. Update and is called from SetCurrentCell. (See the call stack in OnAddedNewRecord). Therefore any calls to SetCurrentCell have no effect because after OnAddedNewRecord returns the callling SetCurrentCell method will continue its job and reposition the current cell.

To work around this behavior override SetCurrentCell as follows:

// reset  bool attribute
m_bAddedANewRecord = FALSE;

// call base class version (maybe also call LockUpdate(TRUE))
grid::SetCurrentCell

// check bool attribute
if (m_bAddedANewRecord )
   SetCurrentCelL....

// reset attribute
m_bAddedANewRecord = FALSE;

in your OnAddedNewRecord method set the m_bAddedNewRecord attribute (and don't call SetCurrentCell)


   m_bAddedNewRecord = TRUE

See Also

CGXBrowserGrid::Update

CGXBrowserGrid

Class Overview | Class Members