Contents Previous Next Subchapters

Using A List Box In A Dialog Window
See Also multilist

Description
Dialog "listbox" controls are used to display a static list from which the user may select one item. These controls behave identical to multilist controls with the exception that only one item may be selected.

addcontrol(
captiongeometry, "listbox", list)
addcontrol(
captiongeometry, "listbox", listcall back)
Adds a "listbox" control, with the specified geometry , to the window specified by caption . The geometry specifies the size of the list box. The character matrix list specifies the choices in the list box. The command specified by call back is executed whenever the current selection in the list is changed by the user. The return value is the control handle for the list box.

getcontrol(
handle)
Returns the current section in the "listbox" control specified by handle, where handle is the value returned by addcontrol when the "listbox" control was created. The return value is a logical column vector with the same row dimension as list in the corresponding call to addcontrol.

setcontrol(
handlelist)
Changes the list of choices in the "listbox" control specified by handle to the list specified by list, where handle is the value returned by addcontrol when the "listbox" control was created and list is a character matrix. The return value of setcontrol is true, if the control can be set as requested, and false otherwise.

Example
The following program creates a dialog window with a push button labeled "Print" and a "listbox" control. When the button is pressed, the value corresponding to the "listbox" control is transposed and printed in the Command window.

clear
#
caption  = "List Box Example"
geometry = [100, 100, 250, 200]
callback = "delwin(caption);"
adddialog(caption, geometry, callback);
#
geometry = [10, 10, 140, 100]
list     = {"One", "Two", "Three"}
Handle   = addcontrol(caption, geometry, "listbox", list )
#
geometry = [35, 145, 90, 20]
name     = "Print"
callback = "Print"
addcontrol(caption, geometry, "pushbutton", name, callback);
#
function Print() begin
     global Handle
     print getcontrol(Handle)'
end