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 of 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 height of the drop-down list in the form's current metric units.

dropDownWidth

 

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

maxLength

 

Specifies the maximum number of characters allowed.

selectAll

true

Whether the selectAll behavior is used in the entry field portion of the ComboBox

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

beforeCloseUp

 

Fires just before dropdown list is closed for a style 1 or 2 combobox

beforeDropDown

 

Fires just before dropdown list opens for a style 1 or 2 combobox

beforeEditPaint

 

For a style 0 or 1 combobox, fires for each keystroke that modifies the value of the combobox, just before the new value is displayed

key

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

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

onChange

 

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

onChangeCancel

 

Fires when the user takes an action that closes the dropdown list without choosing an item from the list for a style 1 or 2 combobox

onChangeCommitted

 

Fires when the user takes an action to choose an item from the list such as by left clicking the mouse on an item or pressing Enter with an item highlighted.

onEditPaint

 

For a style 0 or 1 combobox, fires for each keystroke that modifies the value of the combobox, just after the new value is displayed

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

systemTheme

tabStop

top

visible

width

beforeRelease
onClose

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.