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

# TCustomShellTreeView.Collapse

Removes child nodes (if needed) when the specified tree node is collapsed.

## Declaration

Source position: shellctrls.pas line 113

`protected procedure TCustomShellTreeView.Collapse(`
`Node: TTreeNode`
`); override;`

## Arguments

`Node` |  | Tree node affected in the method.

## Description

Collapse is an overridden method in TCustomShellTreeView used to update the tree node specified in Node when it changes from the expanded to the collapsed state. It uses the value in the ExpandCollapseMode property to determine whether existing child nodes are removed from the collapsed tree node.

When ExpandCollapseMode is set to ecmCollapseAndClear, the DeleteChildren method in Node is called to free its child nodes. The operation is performed in a BeginUpdate / EndUpdate block to prevent updates to the control while the child nodes are deleted.

Collapse calls the inherited method prior to exit to update scroll bars on the control and to signal the OnCollapsed event handler (when assigned).

No actions are performed in the method when ComponentState is set to csDestroying.

Collapse is called when a tree node has executed its Collapse method.

## Version info

Added in LCL version 3.0.

## See also

TCustomShellTreeView.ExpandCollapseMode |  | Controls the actions performed when a tree node is expanded or collapsed on the control.
TCustomTreeView.Collapse |  | Performs actions needed when the specified tree node is collapsed.
TCustomTreeView.OnCollapsed |  | Event handler signalled when a tree node has been collapsed on the control.
TTreeNode.Collapse |  | Collapses the current tree node, and optionally collapses any descendent nodes.
TTreeNode.HasChildren |  | Indicates whether the tree node has child nodes.
TTreeNode.DeleteChildren |  | Removes all child nodes and descendants in the tree structure.
TComponent.ComponentState