OnWrappingRow - cCJGrid
Sent when Next or Previous navigation will result in a row change. Can be used to customize the wrapping behavior.
Type: Event
Parameters
| Parameter | Type | Description |
|---|---|---|
| bForwardWrap | Boolean | True if this is a forward (Next) wrap, False if backwards (Previous). |
| hoToColumn | Handle | The column object that will take the focus. |
| ByRef bWrapRow | Boolean | Passed True, if you wish to stay within the current row, set this to False. |
| ByRef bCancel | Boolean | Passed False, set True to cancel the Next or Previous navigation event. |
Syntax
Procedure OnWrappingRow Boolean bForwardWrap Handle hoToColumn ByRef Boolean bWrapRow ByRef Boolean bCancel
Description
When a Next or Previous navigation will result in a row wrap (i.e., a row change), the default behavior is to allow this change and to attempt to navigate to the new row. If this is not the desired behavior, you can use OnWrappingRow to stay with the same row, cancel the navigation or to activate a different object altogether.
bForwardWrap and hoToColumn are passed to this event so you can use this information to customize the behavior as you see fit.
If you wish wrapping to stay within the same row, set bWrapRow to False. In this example, forward navigation will change rows, but backwards navigation will wrap within the same row:
Procedure OnWrappingRow Boolean bForwardWrap Handle hoToColumn Boolean ByRef bWrapRow Boolean ByRef bCancel
If (Not(bForwardWrap) Begin
Move False to bWrapRow
End
End_Procedure
If you wish to cancel the navigation, set bCancel to false. In this example, forward navigation will change rows, but backwards navigation will do nothing:
Procedure OnWrappingRow Boolean bForwardWrap Handle hoToColumn Boolean ByRef bWrapRow Boolean ByRef bCancel
If (Not(bForwardWrap) Begin
Move False to bWrapRow
End
Else Begin
Move True to bCancel
End
End_Procedure
If you wish to navigate to another object during a wrap, you may activate the object within this event and set bCancel to True (informing Next and Previous that you've handled the navigation). In this example, forward navigation will activate a text edit object, while backwards navigation will switch rows within the grid.
Procedure OnWrappingRow Boolean bForwardWrap Handle hoToColumn Boolean ByRef bWrapRow Boolean ByRef bCancel
If bForwardWrap Begin
Move True to bCancel
Send Activate to oCalls_Notes
End
End_Procedure
In this example, a forward wrap will navigate as above, but a backwards wrap will move to the previous row and then activate the text edit object. Because a row change may involve a save, which can fail, we must check to see if the row change was a success.
Procedure OnWrappingRow Boolean bForwardWrap Handle hoToColumn Boolean ByRef bWrapRow Boolean ByRef bCancel
Handle hoDataSource
Integer iCurRow iNewRow
// previous/next will not do what they normally do
Move True to bCancel
If bForwardWrap Begin
Send Activate to oCalls_Notes
End
Else Begin
// get current row number
Get phoDataSource to hoDataSource
Get SelectedRow of hoDataSource to iCurRow
Send MoveUpRow
// check if the row changed, i.e. we are NOT in the first row
// if we are in the first row and going backwards, we do not move
Get SelectedRow of hoDataSource to iNewRow
If (iNewRow <> iCurRow) Begin
Send Activate to oCalls_Notes
End
End
End_Procedure