ListBox (statement)


ListBox X,Y,width,height,ArrayVariable,.Identifier


Creates a list box within a dialog box template.


When the dialog box is invoked, the list box will be filled with the elements contained in ArrayVariable.

This statement can only appear within a dialog box template (that is, between the Begin Dialog and End Dialog statements).

The ListBox statement requires the following parameters:





X, Y

Integer coordinates specifying the position of the control (in dialog units) relative to the upper left corner of the dialog box.


width, height

Integer coordinates specifying the dimensions of the control in dialog units.



Specifies a single-dimensioned array of strings used to initialize the elements of the list box. If this array has no dimensions, then the list box will be initialized with no elements. A runtime error results if the specified array contains more than one dimension.

ArrayVariable can specify an array of any fundamental data type (structures are not allowed). Null and Empty values are treated as zero-length strings.



Name by which this control can be referenced by statements in a dialog function (such as DlgFocus and DlgEnable). This parameter also creates an integer variable whose value corresponds to the index of the list box's selection (0 is the first item, 1 is the second, and so on). This variable can be accessed using the following syntax:



This example creates a dialog box with two list boxes, one containing files and the other containing directories.

Sub Main()
  Dim files() As String
  Dim dirs() As String
  Begin Dialog ListBoxTemplate 16,32,184,96,"Sample"
    Text 8,4,24,8,"&Files:"
    ListBox 8,16,60,72,files$,.Files
    Text 76,4,21,8,"&Dirs:"
    ListBox 76,16,56,72,dirs$,.Dirs
    OKButton 140,4,40,14
    CancelButton 140,24,40,14
  End Dialog
  FileList files
    FileDirs dirs

  Dim ListBoxDialog As ListBoxTemplate
  rc% = Dialog(ListBoxDialog)
End Sub

See Also

CancelButton (statement); CheckBox (statement); ComboBox (statement); Dialog (function); Dialog (statement); DropListBox (statement); GroupBox (statement); OKButton (statement); OptionButton (statement); OptionGroup (statement); Picture (statement); PushButton (statement); Text (statement); TextBox (statement); Begin Dialog (statement), PictureButton (statement).

More information