BBjGrid::setSnapToRowHeight

Description

In BBj 6.00 and higher, this method sets whether the grid will adjust its height so that it does not display any 'partial' rows.

Syntax

Return Value

Method

void

setSnapToRowHeight(boolean shouldSnap)

Parameters

Variable

Description

shouldSnap

Specifies whether the grid should modify its size to show only complete rows.

Return Value

None.

Remarks

By default, snapToRowHeight is true.

Example

rem 'Snap to Row Height example

rem 'Obtain the instance of the BBjAPI object
let myAPI!=BBjAPI()

rem 'Open the SysGui device
SYSGUI=UNT
OPEN (SYSGUI) "X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui!=myAPI!.getSysGui()

rem 'Set addWindow param values
X=10
Y=10
WIDTH=400
HEIGHT=260
TITLE$="Snap to Row Height"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$)

rem 'Add a grid on the window
myGrid! = myWindow!.addGrid(101,50,50,280,120,$8060$,10,3)
myButton! = myWindow!.addButton(102,140,190,90,30,"Snap On",$$)

rem 'Set the grid properties
myGrid!.setDefaultColumnWidth(130)
myGrid!.setGridEditable(1)
myGrid!.setVerticalScrollable(1)

rem 'Add text to the grid cells
FOR ROW = 0 TO 9
    FOR COL = 0 TO 2
        CELLTEXT$="ROW = " + STR(ROW+1) + ", COL = " + STR(COL+1)
        myGrid!.setCellText(ROW,COL,CELLTEXT$)
    NEXT COL
NEXT ROW

rem 'Register the CALLBACK routines
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())
myButton!.setCallback(myButton!.ON_BUTTON_PUSH,"SNAP_TO_ROW_HEIGHT")

rem 'Process Events
process_events

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

SNAP_TO_ROW_HEIGHT:
    rem 'turn snapToRowHeight on or off based on button text
    if (MyButton!.getText() = "Snap on") then
        myGrid!.setSnapToRowHeight(1)
    else
        myGrid!.setSnapToRowHeight(0)
    endif

    rem 'set button text based on getSnapToRowHeight()
    if myGrid!.getSnapToRowHeight() then myButton!.setText("Snap off") else myButton!.setText("Snap on")
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.