Sign in Join
FPDoc Onlineexperiment

TCustomListView.Selected property

Member of TCustomListViewpublicIn unit ComCtrls

Contains the selected list item in the list view control.

Declaration

pascal
property Selected: TListItem read GetSelection write SetSelection;

Description

Selected is a TListItem property which contains the selected list item in the list view control. Assign a value from the Items property to select the list item.

When MultiSelect is enabled, Selected represents the first entry in Items that has its Selected property set to True. If none of the list items has its Selected property set to True, or SelCount is 0, the property value is Nil.

When OwnerData (or Virtual Mode) is enabled, Selected refers to the most recent owner data item retrieved when the value in ItemIndex was changed. If the item index was set to -1, the property value is Nil.

When both OwnerData and MultiSelect are enabled, Selected refers to the first entry in Items with its Selected property set to True. If none of the list items has its Selected property set to True, the property value is Nil.

Setting a new value for Selected causes the affected list item(s) in the Items property to be updated. In single select mode (MultiSelect = False), the Selected property in the current list item is set to False prior to updating the property value. In MultiSelect mode, a list item assigned as the new property value causes its Selected property to be set to True in the Items for the control.

Set Selected to Nil to clear the current selection(s) in the control. When MultiSelect is enabled, this causes all of the entries in Items to reset their Selected properties to False. In short, setting Selected to Nil clears any existing multi-selections in Items.

Setting a new value for the property causes the OnChange and OnSelectItem event handlers to be signalled (when assigned) when the LVN_ITEMCHANGED notification message is handled for the control. If both handlers are assigned, both handlers are signalled.

Assigning a list item to Selected that is not owned by the current list view control causes an exception to be raised.

Use ClearSelection to clear the Selected attribute for all single or multi-selected Items in the control.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.