BBjWindow::addDataBoundGrid

Description

In BBj 7.0 and higher, this method creates a data bound grid control in the BBjWindow.

Syntax

Return Value

Method

BBjDataBoundGrid

addDataBoundGrid(int ID, number x, number y, number w, number h)

BBjDataBoundGrid

addDataBoundGrid(int ID, number x, number y, number w, number h, string flags)

Parameters

Parameter 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.
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.
w Width of the control in current units.
h 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:
FlagDescription
$0001$Sets the grid control to be initially disabled.
$0002$Creates a managed grid control as a column 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.

Return Value

This method returns the created BBjDataBoundGrid object.

Remarks

The number of rows and columns will be determined by the BBjRecordSet to which the BBjDataBoundGrid is bound.

Example

rem 'Data-bound controls with a Standard Navigator

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

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

rem 'Obtain the instance of the BBjSysGui object
let SysGui! = API!.getSysGui()

rem ' Create the data file
endif  LENAME$="State2.dat"
MODES$=""
TEMPLATE$="STATE:C(2),STARTSWA:C(1),NAME:C(16* = 0)"
erase FILENAME$,err=*next
mkeyed FILENAME$,[0:1:2],0,32
channel = unt
open (channel)FILENAME$
dim REC$:TEMPLATE$

rem ' Load the file with state codes and names
while 1
    dread rec.state$,rec.startsWA$,rec.name$,END=*break
    write record (channel)rec$
wend
close (channel)

rem ' Create the RecordSet
RecordSet! = BBJAPI().createFileRecordSet(FILENAME$,MODES$,TEMPLATE$)

rem 'Set addWindow param values
X = 20
Y = 40
WIDTH = 600
HEIGHT = 400
TITLE$="Data-bound controls sample"

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

rem 'Create a window
Window! = SysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$00010002$)

Window!.addStaticText(101,50,50,100,25,"State:")
state! = Window!.addEditBox(201,100,50,40,25,"")
state!.setEditable(0)
state!.bindRecordSet(RecordSet!,"state")

staticText! = Window!.addStaticText(220, 180, 50, 100, 25, "Starts with A ?")

starts! = Window!.addEditBox(221, 300, 50, 40,25,"")
starts!.setEditable(1)
starts!.bindRecordSet(RecordSet!, "StartsWA")

checkBox! = Window!.addCheckBox(222,350,50,25,25,"starts w A")
checkBox!.setEditable(1)
checkBox!.bindRecordSet(RecordSet!,"StartsWA")

boundGrid! = Window!.addDataBoundGrid(410,50,250,200,100,$8040$)
boundGrid!.setFitToGrid(4)
boundGrid!.setEditable(1)

boundGrid!.bindRecordSet(RecordSet!)
boundGrid!.setDefaultColumnHeaders()
boundGrid!.setColumnStyle(1, boundGrid!.GRID_STYLE_CHECKED)

boundGrid!.setRowHeight(16)
boundGrid!.setCallback(boundGrid!.ON_DB_GRID_ROW_CHANGE_REQUEST, "rowChangeRequest")

Window!.addStaticText(102,50,100,100,25,"Name:")
name! = Window!.addEditBox(202,100,100,200,25,"")
name!.bindRecordSet(RecordSet!,"name")

static2! = Window!.addStaticText(333,100, 130, 200,25,"")
static2!.bindRecordSet(RecordSet!, "name")

Navigator! = Window!.addNavigator(100,50,150,250,30,"Navigator")
Navigator!.bindRecordSet(RecordSet!,"state")
Navigator!.setCallback(Navigator!.ON_NAV_FIRST,"first")
Navigator!.setCallback(Navigator!.ON_NAV_PREVIOUS,"previous")
Navigator!.setCallback(Navigator!.ON_NAV_NEXT,"next")
Navigator!.setCallback(Navigator!.ON_NAV_LAST,"last")

Window!.setCallback(Window!.ON_CLOSE,"APP_CLOSE")
process_events

first:
    gosub save
    RecordSet!.first()
return

previous:
    gosub save
    RecordSet!.previous(err=*next)
return

next:
    gosub save
    RecordSet!.next(err=*next)
return

last:
    gosub save
    RecordSet!.last()
return

save:
    if (RecordSet!.isCurrentRecordDirty()) then
        print 'rb',
        RecordSet!.update(RecordSet!.getCurrentRecordData())
    endif
return

rowChangeRequest:
    gosub save
    event! = sysGui!.getLastEvent()
    row = event!.getRow()
    col = event!.getColumn()
    x = x+1
    prnumber x, " moving to ", row, "," ,cols
    RecordSet!.moveToRecord(row)
    boundGrid!.setSelectedColumn(col)
return

APP_CLOSE:
release

DATA "AK","1","Alaska"
DATA "AL","1","Alabama"
DATA "AR","1","Arkansas"
DATA "AZ","1","Arizona"
DATA "CA","0","California"
DATA "CO","0","Colorado"
DATA "CT","0","Connecticut"
DATA "DC","0","District of Columbia"
DATA "DE","0","Delaware"
DATA "FL","0","Florida"
DATA "GA","0","Georgia"
DATA "GU","0","Guam"
DATA "HI","0","Hawaii"
DATA "IA","0","Iowa"
DATA "ID","0","Idaho"
DATA "IL","0","Illinois"
DATA "IN","0","Indiana"
DATA "KS","0","Kansas"
DATA "KY","0","Kentucky"
DATA "LA","0","Louisiana"
DATA "MA","0","Massachusetts"
DATA "MD","0","Maryland"
DATA "ME","0","Maine"
DATA "MI","0","Michigan"
DATA "MN","0","Minnesota"
DATA "MO","0","Missouri"
DATA "MS","0","Mississippi"
DATA "MT","0","Montana"
DATA "NC","0","North Carolina"
DATA "ND","0","North Dakota"
DATA "NE","0","Nebraska"
DATA "NH","0","New Hampshire"
DATA "NJ","0","New Jersey"
DATA "NM","0","New Mexico"
DATA "NV","0","Nevada"
DATA "NY","0","New York"
DATA "OH","0","Ohio"
DATA "OK","0","Oklahoma"
DATA "OR","0","Oregon"
DATA "PA","0","Pennsylvania"
DATA "PR","0","Puerto Rico"
DATA "RI","0","Rhode Island"
DATA "SC","0","South Carolina"
DATA "SD","0","South Dakota"
DATA "TN","0","Tennessee"
DATA "TX","0","Texas"
DATA "UT","0","Utah"
DATA "VA","0","Virginia"
DATA "VI","0","Virgin Islands"
DATA "VT","0","Vermont"
DATA "WA","0","Washington"
DATA "WI","0","Wisconsin"
DATA "WV","0","West Virginia"
DATA "WY","0","Wyoming"
end

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

BBjRecordSet

GRID Mnemonic

Grid Callbacks

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