Objective Grid: Problems with calling SetCurrentCell() from OnAddedNewRecord().

Article ID: 109
Last updated: 22 Jun, 2018
Article ID: 109
Last updated: 22 Jun, 2018
Revision: 4
Views: 2671
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 22 Jun, 2018
by Meltreger B.

Problem


Problems with calling

SetCurrentCell

() from

OnAddedNewRecord

().


Cause



Action


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 calling 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

This article was:   Helpful | Not helpful
Report an issue
Article ID: 109
Last updated: 22 Jun, 2018
Revision: 4
Views: 2671
Posted: 12 Jan, 2001 by Meltreger B.
Updated: 22 Jun, 2018 by Meltreger B.

Others in this category