<< Return to Main Index

< Return to Class Index

CGXGridCore::SetCurrentCell

virtual BOOL SetCurrentCell(ROWCOL nRow, ROWCOL nCol, UINT flags = GX_SCROLLINVIEW | GX_UPDATENOW);

nRow

Specifies the new row id for the current cell.

nCol

Specifies the new column id for the current cell.

flags

Specifies the update technique. The following flags can be composed:

Return Value

TRUE if the new current cell could be selected; it is FALSE if selecting the new current cell failed, e.g., when the previous cell’s data are not valid.

Remarks

Overridable command which selects a new current cell.

Selecting a new current cell results in deselecting the current cell, storing changes and, finally, selecting the new cell.

First, the current cell is deactivated. By calling CanSelectCurrentCell, the method ensures that the current cell can be deactivated. CanSelectCurrentCell will fire an OnValidateCell event if the cell’s contents were changed.  If CanSelectCurrentCell returns TRUE, the CGXControl-object for the cell (determined through GetControl) is asked if the cell's contents have changed and if they were changed, CGXControl::Store will be called. After that, an OnEndEditing event will be fired.

If OnEndEditing returned TRUE, the current cell will be deselected. At this time, when the grid has no current cell, OnLeftCell will be fired. OnLeftCell normally returns TRUE. If you want to hook into redrawing the old cell, you can override OnLeftCell and return FALSE.

Next, the method calls CanSelectCurrentCell to ensure that the current cell can be set to the specified cell. If CanSelectCurrentCell returns TRUE, the coordinates for the current cell are stored with StoreCurrentCell and the associated CGXControl-object is told to refresh itself or draw a frame around the cell. This behavior depends on the m_bRefreshOnSetCurrentCell attribute. If either CGXGridCore::m_bRefreshOnSetCurrentCell or CGXControl::m_bRefreshOnSetCurrentCell is TRUE, the cell will be refreshed (= completely redrawn). Otherwise, only a frame will be drawn around the cell (so that there is less flickering).

With the next call to OnGridDraw, all changes will be made visible. If you have specified GX_UPDATENOW as update-technique, UpdateWindow is called after deactivating the old cell and after activating the new cell.

Setting the current cell active is done with CGXControl::SetActive.

If CGridParam::IsSyncCurrentCell is TRUE, the method creates the following hint:

   CGXGridHint hint(gxHintSyncCurrentCell, m_nViewID);
   hint.nRow1 = nRow;
   hint.nCol1 = nCol;
   hint.flags = (flags | GX_NOSETFOCUS | GX_NOSYNCCURRENTCELL) & ~GX_SCROLLINVIEW;

See Also

CGXGridCore::CanSelectCurrentCell CGXGridCore::OnValidateCell CGXGridCore::OnEndEditing CGXGridCore::OnLeftCell CGXGridCore::m_bRefreshOnSetCurrentCell CGXControl

CGXGridCore

Class Overview | Class Members