BB___LISTBOX

=LISTBOX= toc

Description
> A LISTBOX is a //control// on a GUI window that consists of a list of items a user can select from. > Listboxes are simple versions of Comboboxes.

Syntax notes

 * //**#handle.ext**// Must be a unique .extension so commands can be written to control after window is opened.
 * //**array$**// The string array contains the items that are displayed in the listbox //after// the window is opened.
 * //**eventHandler**// The branch label or subroutine where program flow continues //after// an item is selected from the listbox.
 * //**x, y**// The x and y coordinates which position the listbox from the upper left corner of the window.
 * //**wide and high**// The width and height of the control.

Listbox Features

 * //**Selection.**// The user can select from the list by double clicking an item. (Double click is the default, but you may specify "singleclickselect" after the window is opened).
 * //**Loading the array.**// To display items in the listbox, the array must be loaded before the window is opened. The array may be loaded by coding the literal strings in the program listing, by using DATA and READ statements, or by inputting data from a disk file.
 * //**Changing the Contents.**// To add or remove an item from the listbox, you must add it or remove it to/from the array. Before the change will show up in the listbox drop-down list, a RELOAD command must be issued. Issueing a RELOAD at any time updates the contents of the listbox.
 * //**Width and Height.**// The size of the control is fixed by **wide** and **high** parameters. The width does not increase if an item is longer than what is specified. If there are more items in the list than will fit within the height, a vertical scroll bar is added. Unlike the drop-down list of a combobox control, the listbox size does not shrink and grow to fit tne contents.

Listbox Commands
The following commands (Methods) can be used with listbox controls. See the individual pages for discussion. print #handle.ext, "contents? varName$" print #handle.ext, "disable" print #handle.ext, "enable" print #handle.ext, "font fontName pointsize" print #handle.ext, "reload" print #handle.ext, "select string" print #handle.ext, "selectindex i" print #handle.ext, "selection? selected$" print #handle.ext, "selectionindex? index" print #handle.ext, "setfocus" print #handle.ext, "singleclickselect"

Listbox Variables
The following variables can be used with listbox controls. See the individual pages for discussion. ListboxColor$

Example
A listbox demo with branch label event handler. code format="lb" nomainwin a$(1) = "one" a$(2) = "two" a$(3) = "three" a$(4) = "four"

listbox #win.listbo, a$,[doListbo],10,10,120,200 open "Listbox Demo" for window as #win
 * 1) win "trapclose [Quit]"
 * 2) win.listbo "selectindex 1"

wait

[Quit] close #win:end

[doListbo] notice "You chose ";sel$ wait code
 * 1) win.listbo "selection? sel$"

A listbox demo with subroutine event handler. code format="lb" nomainwin a$(1) = "one" a$(2) = "two" a$(3) = "three" a$(4) = "four"

listbox #win.listbo, a$,doListbo,10,10,120,200

open "Listbox Demo" for window as #win
 * 1) win "trapclose Quit"
 * 2) win.listbo "selectindex 1"

wait

sub Quit handle$ close #handle$ end end sub

sub doListbo handle$ notice "You chose ";sel$ end sub code
 * 1) handle$ "selection? sel$"

Useful Functions
code format="lb" Place a useful function using this command here code