BBjWindow::addGrid

Description

Creates a grid control in the BBjWindow.

Syntax

Return Value

Method

BBjStandardGrid

addGrid(int ID, int x, int y, int width, int height)

BBjStandardGrid

addGrid(int ID, int x, int y, int width, int height, string flags)

BBjStandardGrid

addGrid(int ID, int x, int y, int width, int height, string flags, int rows, int columns)

BBjStandardGrid

addGrid(int ID, int rowHeaderID, int columnHeaderID, int x, int y, int width, int height)

BBjStandardGrid

addGrid(int ID, int rowHeaderID, int columnHeaderID, int x, int y, int width, int height, string flags)

BBjStandardGrid

addGrid(int ID, int rowHeaderID, int columnHeaderID, int x, int y, int width, int height, string flags, int rows, int columns)

Parameters

Variable

Description

ID

A positive integer that will be used to identify the grid. This number must be unique among the controls in the current window.

RowHeaderID

A positive integer that will be used to identify the rowHeader of the grid. This number must be unique among the controls in the current window.

ColumnHeaderID

A positive integer that will be used to identify the columnHeader of the grid. This number must be unique among the controls in the current window.

x

Horizontal position of the upper-left corner of the grid in currently-scaled CONTROL units, relative to the inside of the window containing it.

y

Vertical position of the upper-left corner of the grid in currently-scaled CONTROL units, relative to the inside of the window containing it.

width

height

Width of the control in current units.

Height of the control in current units.

flags

May be empty or a two-byte binary string composed of any hexadecimal addition of the following values:

 

Flag 

Description

 

$0001$

Sets the grid control to be initially disabled.

 

$0002$

Creates a managed grid control as a column heading.

 

$0004$   

Creates a managed grid control as a row heading.

 

$0008$

Allows users to resize grid columns.

 

$0010$

Sets the grid to be initially invisible. The grid can be made visible with the following command:

print(sysgui) 'show'(id)

 

$0020$

Draws vertical lines between columns in Visual PRO/5 2.0x. In Visual PRO/5 2.10 and higher, use flag $8000$ to draw vertical lines. The default behavior in Visual PRO/5 2.10 and higher is for this flag to do nothing. However, if the 2.10 backward compatibility SETOPTS bit (byte 7, bit $08$) is set, this flag will cause vertical lines to be drawn.

 

$0040$

Draws horizontal lines between rows.

 

$0080$

Includes a horizontal scroll bar with the control.

 

$0100$

Includes a vertical scroll bar with the control.

 

$0800$

Creates a three-dimensional recessed client edge around the control. Note that the client edge is displayed inside the control's bounding rectangle, slightly reducing the visible area of the grid.

 

$1000$

Creates a three-dimensional raised edge around the control. Note that the raised edge is displayed inside the control's bounding rectangle, slightly reducing the visible area of the grid.

 

$8000$

Draws vertical lines between columns.

rows

Sets the number of rows.

columns

Sets the number of columns.

Return Value

Returns the created BBjGrid object.

Remarks

By default, the grid will have 3 rows and 3 columns.

Example

REM Add a grid to a window

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=400
TITLE$="BBj Window"

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,100,300,300,$8060$,4,2)

REM Set the grid's column width
myGrid!.setDefaultColumnWidth(130)

REM Add text to the grid cells
FOR ROW = 0 TO 3
   FOR COL = 0 TO 1
      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_GRID_CELL_MODIFY,GRID_CELL_MODIFIED,mySysGui!.getContext(),myGrid!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

REM Process Events
PROCESS_EVENTS

REM Callback routine called when the contents of a cell are modified
GRID_CELL_MODIFIED:
REM Display a message with the edit box contents
MESSAGE$="Cell modified"
LET X=MSGBOX(MESSAGE$)
RETURN

REM Callback routine called when the user closes the application window
APP_CLOSE:
RELEASE
RETURN

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

`GRID' Mnemonic

Grid Callbacks

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