ListBox

Syntax

ListBox HorizPos, VertPos, Width, Height, ArrayVariable$(), .Identifier

Remarks

Creates a list box from which a user can select an item in a custom dialog box.

Argument

Explanation

HorizPos, VertPos

The horizontal and vertical distance from the upper-left corner of the list box to the upper-left corner of the dialog box, in increments of 1/8 and 1/12 of the System font (Windows) or the dialog font (Macintosh).

Width, Height

The width and height of the list box, in increments of 1/8 and 1/12 of the System font (Windows) or the dialog font (Macintosh).

ArrayVariable$()

A string array containing the list, one list box item per array element.

.Identifier

Together with the dialog record name, .Identifier creates a variable whose value corresponds to the number of the selected list box item. The form for this variable is DialogRecord.Identifier (for example, dlg.MyList).

The identifier string (.Identifier minus the period) is also used by statements in a dialog function that act on the list box, such as DlgEnable and DlgVisible.


Example

This macro displays a list of menu names. First, it creates an array of menu names to be presented in a list box, then it defines a dialog box containing the list box, and finally it displays the dialog box.


Sub MAIN
Dim MyList$(CountMenus(1) - 1)
For i = 1 To CountMenus(1)
    MyList$(i - 1) = MenuText$(1, i)
Next i
Begin Dialog UserDialog 320, 118, "List Box Example"
Text 27, 8, 129, 13, "This is a list box:"
ListBox 29, 25, 160, 84, MyList$(), .MyList
OKButton 226, 5, 88, 21
CancelButton 226, 29, 88, 21
End Dialog
Dim dlg As UserDialog
x = Dialog(dlg)
End Sub

See Also

Begin Dialog¼End Dialog, ComboBox, DlgListBoxArray, DropListBox