A selection list on a form, from which you can pick multiple items.

Syntax

[<oRef> =] new ListBox(<container> [,<name expC>])

<oRef>

A variable or property—typically of <container>—in which to store a reference to the newly created ListBox object.

<container>

The container—typically a Form object—to which you’re binding the ListBox object.

<name expC>

An optional name for the ListBox object. If not specified, the ListBox class will auto-generate a name for the object.

Properties

The following tables list the properties, events, and methods of interest in the ListBox class.

Property

Default

Description

allowDrop

false

Whether dragged objects can be dropped in the ListBox object

baseClassName

LISTBOX

Identifies the object as an instance of the ListBox class

className

(LISTBOX)

Identifies the object as an instance of a custom class. When no custom class exists, defaults to baseClassName

colorHighlight

HighlightText
/Highlight

The color of selected options

colorNormal

WindowText
/Window

The color of unselected options

curSel

 

The number of the option that has the focus rectangle

dataSource

 

The options strings of the ListBox object

multiple

false

Whether the ListBox object allows selection of more than one option

sorted

false

Whether the options are sorted

transparent

false

Whether the ListBox object has the same background color or image as its container

value

 

The value of the option that currently has focus

 

vScrollBar

Auto

When a vertical scrollbar appears (0=Off, 1=On, 2=Auto, 3=Disabled)

 

Event

Parameters

Description

key

<char expN>,
<position expN>,
<shift expL>,
<ctrl expL>

When a key is pressed in the ListBox. Return value may change or cancel keystroke.

onDragEnter

<left expN>
<top expN>
<type expC>
<name expC>

When the mouse enters the ListBox display area during a Drag&Drop operation

onDragLeave

 

When the mouse leaves the ListBox display area without having dropped an object

onDragOver

<left expN>
<top expN>
<type expC>
<name expC>

While the mouse drags an object over the ListBox display area during a Drag&Drop operation

onDrop

<left expN>
<top expN>
<type expC>
<name expC>

When the mouse button is released over the ListBox display area during a Drag&Drop operation

onKey

<char expN>,
<position expN>,
<shift expL>,
<ctrl expL>

After a key has been pressed (and the key event has fired), but before the next keypress.

onSelChange

 

After the focus moves to another option in the list

 

Method

Parameters

Description

count( )

 

Returns the number of options in the list

selected( )

 

Returns the currently selected option(s) or checks if a specified option is selected

 

The following table lists the common properties, events, and methods of the ListBox class:

Property

 

Event

 

Method

before
borderStyle

dragEffect

enabled

fontBold

fontItalic

fontName

fontSize

fontStrikeout

fontUnderline

form

height

helpFile

helpId

hWnd
id

left

mousePointer

name

pageno

parent

printable

speedTip

statusMessage

systemTheme
tabStop

top

visible

width

onDesignOpen
onDragBegin

onGotFocus

onHelp

onLeftDblClick

onLeftMouseDown

onLeftMouseUp

onLostFocus

onMiddleDblClick

onMiddleMouseDown
onMiddleMouseUp

onMouseMove

onOpen

onRightDblClick

onRightMouseDown

onRightMouseUp

when

drag( )
move( )

release( )

setFocus( )

Description

Use a ListBox object to present the user with a scrollable list of items. If the multiple property is true, the user can choose more than one item. The list of options is set with the dataSource property. The list of items selected is returned by calling the selected( ) method.