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

TCustomListView.Selected

Contains the selected list item in the list view control.

Declaration

Source position: comctrls.pp line 1672

public property TCustomListView.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

TCustomListView.OwnerData

  

Enables or disables owner data (virtual) mode for the list view control.

TCustomListView.MultiSelect

  

Allows simultaneous selection of one or more list items using Ctrl+Click, Shift+Click, Ctrl+Shift+Click, or using program code.

TCustomListView.ItemIndex

  

Ordinal position for the selected list item on the control.

TCustomListView.Items

  

Collection of list items displayed on the list view control.

TCustomListView.ClearSelection

  

Clears the selected items for the list view control.

TCustomListView.SelectAll

  

Selects all Items in the control when MultiSelect has been enabled.

TListItem.Selected

  

Whether this Item has been Selected (often denoted by a check-mark).

TListItems.Count

  

The number of TListItem instances stored in the container.

TOwnerDataListItem.SetDataIndex

  

Sets the index position for the virtual list item and updates the item cache.


Version 3.2 Generated 2024-02-25 Home