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

TCustomComboBox.Text

The value in the edit box for the control.

Declaration

Source position: stdctrls.pp line 442

public property TCustomComboBox.Text : TCaption;

Description

Text is a public property in TCustomComboBox and contains the TCaption value for the control. It is the value displayed in the edit box for the control.

Setting a new value for Text in program code causes the RealSetText method to be called. The new property value is located in the Items property, and the value in ItemIndex is updated with the ordinal position for the found value. A case-insensitive comparison is used to locate the value in Items. The value applied to Text retains the original case used in the new property value. ItemIndex is set to -1 if a value is not located in Items that is a case-insensitive match the new property value.

At run-time, the value in Text can be updated using the edit box for the control when it is enabled for the selected Style (such as csDropDown and csSimple). When Style contains csDropDownList, the edit box is not displayed. But the button for the drop-down list handles the first character key pressed, and locates a value in Items when the button has focus.

AutoComplete enables or disables auto-completion for the value in Text. When set to True, the first item that matches the entered character(s) is located in Items and the value is highlighted in the drop-down list for the control. By default, a case-insensitive comparison is used to find the entered value. Case sensitivity can be enabled using cbactSearchCaseSensitive in the AutoCompleteText options, and requires the value in Items to be an exact case-sensitive match for the character(s) entered in the edit box. Text is updated to contain the complete value for the entry in Items. By default, the case for the value in Items is retained and applied to Text. Include cbactRetainPrefixCase in AutoCompleteText options to use the value as entered in the edit box in the Text property.

When the edit box loses input focus, ItemIndex is updated with the ordinal position in Items where the partial value was found. It is set to -1 when a matching value could not be located in Items.

When AutoComplete is disabled (set to False), the entered value is still located located and highlighted in the drop-down list for Items. However, the value in Text is not expanded and the the value in ItemIndex is not updated. The item must be selected using the drop-down list to apply the value to Text and update the value in ItemIndex.

Use ItemIndex to select one of the Items by its ordinal position, and apply the value to the Text property.

See also

TCustomComboBox.Style

  

Controls the appearance and behavior for the combo-box.

TCustomComboBox.AutoComplete

  

Positions the list box using partial text matching.

TCustomComboBox.AutoCompleteText

  

Options for the behavior of the Auto-Complete feature.

TCustomComboBox.Items

  

The list of items displayed in the combo-box control.

TCustomComboBox.ItemIndex

  

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

TCustomComboBox.ReadOnly

  

Disallows free-form entry of Text into the combo-box edit field.

TComboBoxAutoCompleteText

  

Set of TComboBoxAutoCompleteTextOption values.

TComboBoxAutoCompleteTextOption

  

Defines the behavior of the AutoComplete feature in a combo-box control.


Version 3.2 Generated 2024-02-25 Home