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

# TCustomTreeView.ClearSelection

Clears the selection in the tree view control.

## Declaration

Source position: comctrls.pp line 3711

`public procedure TCustomTreeView.ClearSelection(`
`KeepPrimary: Boolean = False`
`); virtual;`

## Arguments

`KeepPrimary` |  | True if the first node in a multi-selection is kept.

## Description

ClearSelection is a method used to clear tree nodes selected in the tree view control. ClearSelection uses the value in MultiSelect to determine the actions needed to clear the selected nodes.

If MultiSelect has been enabled in the Options for the control, the ClearMultiSelection method is called to clear the selected nodes.

KeepPrimary indicates whether the first tree node in a multi-selection is retained. When set to False, all selected nodes are removed from the Selections property. Otherwise, the tree node in Selected is retained.

If MultiSelect has not been enabled, the value in the Selected property is set to Nil to clear the single node selection.

No actions are performed in the method when MultiSelect is False and KeepPrimary is True.

ClearSelections is called from methods that handle mouse or keyboard selection, like KeyDown and MouseDown. It is also called when a new value is assigned to the MultiSelect property.