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

# TCustomTreeView.SaveToStream

Saves the tree nodes in Items to the specified stream.

## Declaration

Source position: comctrls.pp line 3733

`public procedure TCustomTreeView.SaveToStream(`
`Stream: TStream`
`);`

## Arguments

`Stream` |  | TStream instance where the tree node data is stored.

## Description

SaveToStream is a method used to store a textual representation for the tree nodes in Items to the specified Stream. Stream is the TStream instance where the tree node data is stored.

SaveToStream visits each of the TTreeNode instances in Items and writes the tree node information to the stream. Each node is represented Each tree node is represented by leading Tab (#9) characters to denote the Level for the tree node, followed by the Text for the node and an end-of-line sequence (#13#10).

Remark: | SaveToStream does not change the position in Stream prior to writing node values. It assumes the stream position has been set in the calling routine. It does not reset the stream position when the method has been completed.

Use LoadFromStream to load and create tree nodes in Items from stream-based storage.

Use LoadFromFile and SaveToFile to read and write the node hierarchy using file-based storage.

## See also

TCustomTreeView.Items |  | The container with the TTreeNode instances for the control.
TCustomTreeView.LoadFromStream |  | Loads tree nodes from the specified stream.
TCustomTreeView.LoadFromFile |  | Loads tree nodes from the specified file.
TCustomTreeView.SaveToFile |  | Saves the tree nodes in Items to the specified file.
TTreeNode.Level |  | The number of ancestor nodes for the current tree node.
TTreeNode.Text |  | Text displayed for the tree node.
TTreeNodes |  | Implements a container for TTreeNode instances.