Skip to main content

TdxOcNode.GetNext Method

Returns the next node in the control’s nodes list.

Declaration

function GetNext: TdxOcNode;

Returns

Type
TdxOcNode

Remarks

Call this function recursively to iterate through the nodes and apply the same changes to them. The function returns nil if the current node is the last in the list.

The following code example shows how to apply the selected node’s appearance settings to all the nodes in the tree structure:

//This procedure recursively applies the specific node's appearance settings to the other tree nodes, starting from the specified one
procedure MyForm.ApplyStyleToAll(ASourceNode, ACurrentNode: TdxOcNode);
var
  ANodeInfo: TdxOcNodeInfo;  // Stores the tree node's appearance settings
  AText: string;
begin
  if(ASourceNode = nil) or (ACurrentNode = nil) then Exit;  // Ensures that the following code is executed only in the case of valid parameters
  ASourceNode.GetNodeInfo(ANodeInfo);  // Copies the source node's appearance settings
  AText := ASourceNode.Text;  // Copies the node's text
  ACurrentNode := ACurrentNode.GetNext;  // Obtains the next destination node
  if ACurrentNode = nil then Exit;
  ACurrentNode.Width := ANodeInfo.Width;
  ACurrentNode.Height := ANodeInfo.Height;
  ACurrentNode.Color := ANodeInfo.Color;
  ACurrentNode.Shape := ANodeInfo.Shape;
  ACurrentNode.ImageIndex := ANodeInfo.Index;
  ACurrentNode.ImageAlign := ANodeInfo.IAlign;
  ACurrentNode.ChildAlign := ANodeInfo.Align;
  ACurrentNode.Text := AText;  // Assigns the previously copied text to the node
  ApplyStyleToAll(ACurrentNode, ACurrentNode);  // Calls the ApplyStyleToAll procedure recursively to apply the same settings to the remaining nodes.
end;
// Pass the selected node as the AsourceNode parameter to apply the appearance settings to all the control's nodes, starting from the first one
  ApplyStyleToAll(dxOrgChart1.Selected, dxOrgChart1.RootNode);
See Also