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

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



Article ID: 109
Last updated: 22 Jun, 2018
Revision: 4
Stingray -> Objective Grid -> Objective Grid: Problems with calling SetCurrentCell() from OnAddedNewRecord().
https://rwkbp.makekb.com/entry/109/