[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'StdCtrls' (#lcl)

# TCustomComboBox.ItemIndex

The index of the currently selected item, or -1 if no item is selected.

## Declaration

Source position: stdctrls.pp line 436

`public property TCustomComboBox.ItemIndex : Integer read GetItemIndex write SetItemIndex default - 1;`

## Description

ItemIndex is an Integer property which contains the ordinal position in Items for the current selection in the drop-down list. The first value in Items is at index position 0 (zero). The final value in Items is at the index position ItemCount-1. When no value is selected in the drop-down list, ItemIndex is set to -1. The default value for the property is -1.

When the value for the property is read, the widgetset class is queried if a handle has been assigned for the control.

Assigning a new value to the property causes the value in Text to be updated to reflect the new selection in the control. When ItemIndex is set to -1, Text is set to an empty string ('') and the TextHint for the control is displayed (when assigned).

For platforms which use emulated text hints, the non-native placeholder is displayed or hidden when ItemIndex or Text is changed. -1 causes the value in TextHint to be displayed on the control. Any other value causes the emulated text hint to be hidden. Platforms which support native TextHint placeholders control the hint display in the widget instance.

## See also

TCustomComboBox.Items |  | The list of items displayed in the combo-box control.
TCustomComboBox.AddItem |  | Adds the specified string (and optional object) to the Items displayed in the control.
TCustomComboBox.Text |  | The value in the edit box for the control.
TCustomComboBox.TextHint |  | Default hint text shown when the Text property is empty for the control.
TCustomComboBox.CanShowEmulatedTextHint |  | Indicates whether an emulated TextHint can be displayed for the control.
TCustomComboBox.EmulatedTextHintStatus |  | Status for the emulated TextHint in the control.
TCustomComboBox.AddHistoryItem |  | Add an item as the first entry in the history list for the control.