A component on a form which can be temporarily expanded to show a list from which you can pick a single item.

Syntax

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

<oRef>

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

<container>

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

<name expC>

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

Properties

The following tables list the properties, events, and methods of the ComboBox class.

Property

Default

Description

autoDrop

false

Whether the drop-down list automatically drops down when the combobox gets focus

baseClassName

COMBOBOX

Identifies the object as an instance of the ComboBox class

className

COMBOBOX

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

colorHighlight

WindowText
/Window

The color or the text in the ComboBox object when it has focus

colorNormal

WindowText
/Window

The color of the text in the ComboBox object when it does not have focus

dataLink

 

The Field object that is linked to the ComboBox object

dataSource

 

The option strings of the ComboBox object

dropDownHeight

 

The number of options displayed in the drop-down list

dropDownWidth

 

The width of the drop-down list in the form’s current metric units

sorted

false

Whether the options are sorted

style

DropDown

The style of the ComboBox: 0=Simple, 1=DropDown, 2=DropDownList

value

 

The value of the currently selected option

 

Event

Parameters

Description

key

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

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

onChange

 

After the string in the ComboBox object has changed and the ComboBox object loses focus, but before onLostFocus

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.

Method

Parameters

Description

copy( )

 

Copies selected text to the Windows clipboard

cut( )

 

Cuts selected text to the Windows clipboard

keyboard( )

<expC>

Simulates typed user input to the ComboBox object

paste( )

 

Copies text from the Windows clipboard to the current cursor position

undo( )

 

Reverses the effects of the most recent cut( ), copy( ), or paste( ) action

 

The following table lists the common properties, events, and methods of the ComboBox 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
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 ComboBox object when you want the user to pick one item from a list. When the user is not choosing an item, the list is not visible. The list of options is set with the dataSource property.

If a ComboBox is dataLinked to a field object that has implemented its lookupSQL or lookupRowset properties, the ComboBox will automatically be populated with the appropriate lookup values, and store the corresponding key values in the dataLinked field.