Pointer to the custom data for the node.
Source position: comctrls.pp line 3148
public property TTreeNode.Data : Pointer |
Data is a Pointer property with a pointer to the custom data for the node. Data can contain any arbitrary data type, and must be cast to the correct type when used in an application.
Setting a new value for the property causes the associated TreeView (when assigned) to sort the parent node or all of the TreeNodes when needed and allowed. It is needed when the tree view uses SortType stData or stBoth. It is allowed if the node is not being deleted and is bound to other tree nodes (States).
The Changed method is called with the ncDataChanged node change reason.
type TMyClass = class(Object public Created: string; end; procedure TForm1.Button1Click(Sender: Object var Node: TTreeNode; begin if Assigned(TreeView1.Selected) then Node := TreeView1.Selected else Node := TreeView1.Items.GetFirstNode; with TreeView1.Items.AddChild(Node, Format('Node: %d', [TreeView1.Items.Count])) do begin Data := TMyClass.Create; TMyClass(Data).Created := FormatDateTime('hh:nn:ss',Now); end; end; procedure TForm1.TreeView1SelectionChanged(Sender: Objectew1.Items.Count])) do begin Label1.Caption := 'Node creation time: ' + TMyClass(TreeView1.Selected.Data).Created; end;
CT Web help |
CodeTyphon Studio |