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

# TCustomListBox.GetSelectedText

Get the text for all selected items as a string value.

## Declaration

Source position: stdctrls.pp line 620

`public function TCustomListBox.GetSelectedText: string;`

## Function result

The item strings, one per line.

## Description

GetSelectedText is a String function used to retrieve a string with all selected items in the control. The return values uses each selected entry in Items separated by the LineEnding character sequence for the platform or operating system. The return value is an empty string ('') when ItemIndex does not contain a positive non-zero value (no item is selected) or SelCount contain 0 (zero).

GetSelectedText iterates over the values in Items, and includes the string when its Selected property is set to True. This is useful when MultiSelect is enabled for the control.

## See also

TCustomListBox.Items |  | The list of all items defined in the control.
TCustomListBox.Selected |  | The Selected state for an item in the control.
TCustomListBox.MultiSelect |  | Allows selection of more than one item from the list.
TCustomListBox.SelCount |  | The number of selected items in the list box control.