Column and Row Navigation
Column and row navigation occurs when the user navigates the focused cell from one column to another and/or one row to another. Navigation can occur via keyboard actions or mouse clicks.
Column navigation via the keyboard is enabled by setting the grid's pbFocusSubItems property to True (the default).
Column Navigation
To programmatically navigate to the next grid column (left to right), send the Next message to the grid object. To navigate in the opposite direction, send the Previous message.
The Next and Previous messages send the NextColumn or PreviousColumn message to the SelectedColumnObject to determine which column should take the focus. These messages send CanNavigateIntoColumn to prospective grid column objects.
You can send MoveToColumnObject to move to an arbitrary column. Send MoveToFirstEnterableColumn or MoveToLastEnterableColumn to move to the leftmost or rightmost column that can take the focus.
Column Navigation Events
Grid column objects handle all of the column navigation events:
-
When changing columns in the forward direction (left to right) using the keyboard, the
OnValidatingevent is sent to the old column. You can use this event to validate the data in the column being exited. If the event returns true, validation fails and the forward keyboard navigation is cancelled. -
After
OnValidating, theOnExitingevent is sent to the column being exited. UnlikeOnValidating,OnExitingis sent regardless of how the column navigation occurs or in which direction.OnExitingis also called before the cell navigation has occurred; if it returns true, then the cell navigation is cancelled. -
After
OnExiting, theOnEnteringevent is sent to the grid column being navigated to. Once again,OnEnteringis called before the cell navigation has occurred; if it returns true, then the cell navigation is cancelled. -
After
OnEntering, the column navigation is performed. TheOnExitevent is sent to the column that was exited, then theOnEntryevent is sent to the column that was navigated to.
Row Navigation
Send MoveDownRow or MoveUpRow to the grid object to programmatically move up or down one row. The following messages can be sent to change the current row to the specified position:
Additionally, MoveToRow can be used to move to an arbitrary row number.
Row Navigation Events
-
OnWrappingRowis sent to the grid object when aNextorPreviouscolumn navigation results in a row change. This event can be used to customize the wrapping behavior. The event is fired before the column (and row) navigation occurs. Both the column navigation and/or the row navigation can be cancelled. -
OnRowChangingis sent to the grid object whenever a row change is about to occur. If the event returns true, the row navigation is cancelled. -
OnRowChangedis sent to the grid object after a row change has occurred.