Control Architecture
To completely comprehend the way Objective Grid draws, let’s take a look at how it implements and manipulates the controls for each cell.
Each composed style object for a cell contains an identifier for a control. Like any other style attribute, this identifier can be changed at run time allowing the developer maximum flexibility. The CGXGridCore class maintains a map of registered control types and identifiers. In the CGXGridCore::OnGridInitialUpdate() member function, the developer can register any additional control types with their identifiers by calling RegisterControl().
Another interesting facet of the control implementation is the concept of the current cell. Objective Grid manages the current cell as the user navigates through the grid by clicking or using arrow keys. When the user changes the current cell, the grid resets the attributes of the control bound to the previous current cell and initializes the control of the new current cell. Finally, Objective Grid passes all other events to the control so the end user can interact directly with the control. When the user changes the current cell, the grid object takes over again and the current cell process starts over.
Current Cell Interface
CGXGridCore offers several methods that let the developer manipulate the current cell:
SetCurrentCell()
Selects the current cell at the given coordinates.
GetCurrentCell()
Returns TRUE if a current cell exists and retrieves the cell coordinates of the current cell.
IsCurrentCell()
Returns TRUE if a current cell exists or is the specified cell.
MoveCurrentCell()
Selects a new current cell based on an offset from the existing current cell in a specified direction.
TransferCurrentCell()
Stores and deactivates the current cell or reinitializes the current cell's contents.
Current Cell Notifications
There are many notification methods the developer can override in a CGXGridCore-derived class. Many of the notification methods have related virtual methods in the CGXControl class. You can choose whether you want to override the method for all cells in the grid or only for specific controls.
CanSelectCurrentCell()
Called to determine if the specified cell can be selected or deselected. If the cell is deselected, CanSelectCurrentCell() calls OnValidateCell(); otherwise it returns TRUE.
OnCanceledEditing()
Called after the current cell’s content is canceled and the control has been reinitialized with the previous cell’s data.
OnCancelEditing()
Called when the user presses <ESC> on the current cell. You should return TRUE if the control can be deactivated. If you return FALSE, the control cannot be deactivated.
OnClickedButtonRowCol()
Called when the user presses some sort of button (e.g. a pushbutton, hotspot, or radio button) inside of a grid cell.
OnDeleteCell()
Called when the user presses <DELETE> in the inactive current cell. Returns TRUE if the cell's data can be deleted.
OnEndEditing()
Called when the user confirms the contents of the current cell and they are valid. You should return TRUE if the data can be accepted. If you return FALSE, the data will not be accepted, and the cell will remain in edit mode.
OnInitCurrentCell()
Called when current cell is initialized. CGXControl::Init() fires this event.
DoLButtonDown()
Delegates the standard MFC OnLButtonDown() event from (CGXGridWnd and CGXGridView) to the correct spot of the grid.
OnLButtonClickedRowCol()
Called when the user clicks and releases the left mouse button in a cell.
OnLButtonDblClkRowCol()
Called when the user double-clicks the left mouse button in a cell.
OnLButtonHitRowCol()
Called when the user clicks the left mouse button in a cell. Subsequent calls occur when the mouse is dragged and when the user releases the mouse button.
OnLeftCell()
Called after the grid has deselected the old current cell. You may override this method and redraw the cell or row. If you return FALSE, the cell will not be redrawn by the grid. If you return TRUE (default), the grid will refresh the cell itself.
OnMButtonClickedRowCol()
Called when the user clicks and releases the middle mouse button in a cell.
OnMButtonDblClkRowCol()
Called when the user double-clicks the middle mouse button in a cell.
OnMButtonHitRowCol()
Called when the user clicks the middle mouse button in a cell. Subsequent calls occur when the mouse is dragged and when the user releases the mouse button.
OnModifyCell()
Called when the user changes text in the current cell.
OnMovedCurrentCell()
Called when a new current cell has been selected, but the change is not yet visible.
DoRButtonDown()
Delegates the standard MFC OnRButtonDown() event from (CGXGridWnd and CGXGridView) to the correct spot of the grid.
OnRButtonClickedRowCol()
Called when the user clicks and releases the right mouse button in a cell.
OnRButtonDblClkRowCol()
Called when the user double-clicks the right mouse button in a cell.
OnRButtonHitRowCol()
Called when the user clicks the right mouse button in a cell. Subsequent calls occur when the mouse is dragged and when the user releases the mouse button.
OnStartEditing()
Called when the user presses a key or the mouse on the current cell. Returns TRUE if the control can be activated for editing.
OnValidateCell()
Called after the user has left a modified cell and before another cell is selected. OnValidateCell() can be overridden to perform cell-level validation.
ProcessKeys()
Interprets keystrokes sent either from the current cell’s control or the grid-window.
Predefined Controls
The following control IDs are predefined in Objective Grid. You can use one of the following control IDs in a call to a SetStyleRange() command, without explicitly registering them. Objective Grid will register the control automatically as needed.
Table 2 – Predefined control IDs 
Control ID
Description
GX_IDS_CTRL_EDIT
Edit control
GX_IDS_CTRL_SCROLLEDIT
Edit control with a vertical scroll bar
GX_IDS_CTRL_HOTSPOT
Hot spot or drop edit
GX_IDS_CTRL_SPINEDIT
Spin edit
GX_IDS_CTRL_RICHEDIT
Rich edit control
GX_IDS_CTRL_MASKEDIT
Mask edit control
GX_IDS_CTRL_STATIC
Static text
GX_IDS_CTRL_PUSHBTN
Push button
GX_IDS_CTRL_RADIOBTN
Radio button
GX_IDS_CTRL_RADIOBTN3D
Radio buttons with 3D effect
GX_IDS_CTRL_CHECKBOX
Check box
GX_IDS_CTRL_CHECKBOX3D
Check box with 3D effect
GX_IDS_CTRL_COMBOBOX
Regular combo box; allows user to input any text
GX_IDS_CTRL_TEXTFIT
Regular combo box with text fit; limits user input to entries in the choice list
GX_IDS_CTRL_ZEROBASED
Combo box with zero-based indices; stores and displays the index value
GX_IDS_CTRL_ONEBASED
Combo box with one-based indices; stores and displays the index value
GX_IDS_CTRL_ONEBASED_EX
Combo box with one-based indices; stores the index value but displays the associated choice list text
GX_IDS_CTRL_ZEROBASED_EX
Combo box with zero-based indices; stores the index value but displays the associated choice list text
GX_IDS_CTRL_CBS_DROPDOWN
MFC CComboBox with the CBS_DROPDOWN style
GX_IDS_CTRL_CBS_DROPDOWNLIST
MFC CComboBox with the CBS_DROPDOWNLIST style
GX_IDS_CTRL_TABBED_COMBOBOX
Tabbed combo box
GX_IDS_CTRL_CBS_TABBED_DROPDOWN
Tabbed combo box based on an MFC CComboBox with the CBS_DROPDOWN style
GX_IDS_CTRL_CBS_TABBED_DROPDOWNLIST
Tabbed combo box based on an MFC CComboBox with the CBS_DROPDOWNLIST style
GX_IDS_CTRL_CHECKLIST_COMBOBOX
Drop down checklist combo box
GX_IDS_CTRL_LISTBOX
List box
GX_IDS_CTRL_HEADER
Header
GX_IDS_CTRL_BROWSEARROWHEADER
Row header for browser grids; displays the arrow or pencil icon as appropriate
GX_IDS_CTRL_PROGRESS
Progress bar
GX_IDS_CTRL_PASSWORD
Password edit
GX_IDS_CTRL_DATETIME
Date time control with a pop-up calendar
GX_IDS_CTRL_DATETIMENOCAL
Date time control without a pop-up calendar
GX_IDS_CTRL_CURRENCY
Formatted currency control
Here is an example of using these settings:
 
// Assign a combo box to a cell
SetStyleRange(CGXRange(3,3),
CGXStyle()
.SetControl(GX_IDS_CTRL_COMBOBOX)
.SetChoiceList("one\ntwo\nthree\n")
);