DropListBox (statement)

Syntax DropListBox X, Y, width, height, ArrayVariable, .Identifier
Description Creates a drop list box within a dialog box template.
Comments When the dialog box is invoked, the drop list box will be filled with the elements contained in ArrayVariable. Drop list boxes are similar to combo boxes, with the following exceptions:
  • The list box portion of a drop list box is not opened by default. The user must open it by clicking the down arrow.
  • The user cannot type into a drop list box. Only items from the list box may be selected. With combo boxes, the user can type the name of an item from the list directly or type the name of an item that is not contained within the combo box.
This statement can only appear within a dialog box template (i.e., between the Begin Dialog and End Dialog statements). The DropListBox statement requires the following parameters:
Parameter Description
X, Y Integer coordinates specifying the position of the control (in dialog units) static to the upper left corner of the dialog box.
width, height Integer coordinates specifying the dimensions of the control in dialog units.
ArrayVariable Single-dimensioned array used to initialize the elements of the drop list box. If this array has no dimensions, then the drop 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.
.Identifier 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 drop 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:
Example This example allows the user to choose a field name from a drop list box.
Sub Main()
  Dim FieldNames$(4)
  FieldNames$(0) = "Last Name"
  FieldNames$(1) = "First Name"
  FieldNames$(2) = "Zip Code"
  FieldNames$(3) = "State"
  FieldNames$(4) = "City"
  Begin Dialog FindTemplate 16,32,168,48,"Find"
    Text 8,8,37,8,"&Find what:"
    DropListBox 48,6,64,80,FieldNames,.WhichField
    OKButton 120,7,40,14
    CancelButton 120,27,40,14
  End Dialog
  Dim FindDialog As FindTemplate
  FindDialog.WhichField = 1
  Dialog FindDialog
End Sub
See Also CancelButton (statement); CheckBox (statement); ComboBox (statement); Dialog (function); Dialog (statement); GroupBox (statement); ListBox (statement); OKButton (statement); OptionButton (statement); OptionGroup (statement); Picture (statement); PushButton (statement); Text (statement); TextBox (statement); Begin Dialog (statement), PictureButton (statement).