BBjListBox::fillFromRecordSet

Description

In BBj 4.0 and higher, this method fills the BBjListBox control from the specified record set.

Syntax

Return Value

Method

void

fillFromRecordSet(BBjRecordSet recordset, string fieldname)

Parameters

Variable

Description

recordset

Specifies the record set for populating this list.

fieldname

Specifies the record set field for populating this list.

Return Value

None.

Example

rem 'Data-bound controls sample for fillFromRecordSet

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 ' Create the data file
FILENAME$="State.dat"
MODES$=""
TEMPLATE$="STATE:C(2),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.name$,END=*break
    write record (channel)rec$
wend
close (channel)

rem ' Create a file-based RecordSet
RecordSet! = BBJAPI().createFileRecordSet(FILENAME$,MODES$,TEMPLATE$)

rem 'Set addWindow param values
X = 200
Y = 200
WIDTH = 350
HEIGHT = 200
TITLE$="Data-bound controls sample"

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

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

myWindow!.addStaticText(101,50,10,100,25,"State:")
state! = myWindow!.addStaticText(201,100,10,40,25,"")
state!.bindRecordSet(RecordSet!,"state")

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

myWindow!.addStaticText(103,50,70,150,25,"List:")
list! = myWindow!.addListBox(203,100,70,200,50,"")
list!.fillFromRecordSet(RecordSet!,"name")
list!.bindRecordSet(RecordSet!,"name")

Navigator! = myWindow!.addNavigator(100,50,120,250,30,"Navigator",$$)
Navigator!.setCallback(Navigator!.ON_NAV_FIRST,"firstRecord")
Navigator!.setCallback(Navigator!.ON_NAV_PREVIOUS,"previousRecord")
Navigator!.setCallback(Navigator!.ON_NAV_NEXT,"nextRecord")
Navigator!.setCallback(Navigator!.ON_NAV_LAST,"lastRecord")

toggle! = myWindow!.addButton(1,50,160,80,25,"Unbind")
toggle!.setCallback(toggle!.ON_BUTTON_PUSH,"toggle")

close! = myWindow!.addButton(2,220,160,80,25,"Close")
close!.setCallback(close!.ON_BUTTON_PUSH,"APP_CLOSE")

myWindow!.setCallback(myWindow!.ON_CLOSE,"APP_CLOSE")

process_events

toggle:
    boundRecordSet! = list!.getBoundRecordSet(err = bind)
    list!.unbindRecordSet()
    toggle!.setText("Bind")
return

bind:
    list!.bindRecordSet(RecordSet!,"name")
    toggle!.setText("Unbind")
return

firstRecord:
    RecordSet!.first()
return

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

nextRecord:
    RecordSet!.next(err=*next)
return

lastRecord:
    RecordSet!.last()
return

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

APP_CLOSE:
release

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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