method Nodes.Remove (Index as Variant)
Removes a specific member from the Nodes collection.

TypeDescription
Index as Variant A string expression that specifies the key of the node, a long expression that indicates the index of the node, a Node object that specifies the node being removed.

Use the Remove method to remove a child node. Use the Clear method to clear all nodes in the collection. The Root node ( Index = 0 ) can't be removed. Use the RemoveAssistant method to remove an assistant node. The IsAssistant property specifies whether a node is a child node or an assistant node. Use the ShowAssistants property to hide all assistant nodes. Use the Expanded property to collapse a node. The Remove method does not remove recursively the child nodes. Use the Remove method of the Node object to remove recursively the child nodes, the assistant nodes and all the nodes in the same group, and if possible remove the node itself.

The following VB sample removes recursively the node all all its child nodes:

Private Sub removeRec(ByVal chart As EXORGCHARTLibCtl.ChartView, ByVal n As EXORGCHARTLibCtl.Node)
    Dim c As EXORGCHARTLibCtl.Node
    Set c = n.FirstNode
    While Not (c Is Nothing)
        Dim x As EXORGCHARTLibCtl.Node
        Set x = c.NextNode
        removeRec chart, c
        Set c = x
    Wend
    If Not (n.Parent Is Nothing) Then
        chart.Nodes.Remove n
    End If
End Sub

The following C++ sample removes recursively the node all all its child nodes:

void removeRec( CChartView* pChart, CNode* pNode )
{
	if ( pNode != NULL )
	{
		CNode child = pNode->GetFirstNode();
		while ( child.m_lpDispatch != NULL )
		{
			CNode next = child.GetNextNode();
			removeRec( pChart, &child );
			child = next;
		}
		if ( pNode->GetParent().m_lpDispatch != NULL )
			pChart->GetNodes().Remove( COleVariant( pNode->GetKey() ) );
	}
}

and you can call the removeRec function like follows:

CNode node( V_DISPATCH( &m_chartview.GetSelectNode() ) );
removeRec( &m_chartview, &node );

The following VB.NET sample removes recursively the node all all its child nodes:

Private Sub removeRec(ByVal chart As AxEXORGCHARTLib.AxChartView, ByVal n As EXORGCHARTLib.Node)
    Dim c As EXORGCHARTLib.Node = n.FirstNode
    While Not (c Is Nothing)
        Dim x As EXORGCHARTLib.Node = c.NextNode
        removeRec(chart, c)
        c = x
    End While
    If Not (n.Parent Is Nothing) Then
        chart.Nodes.Remove(n)
    End If
End Sub

The following C# sample removes recursively the node all all its child nodes:

private void removeRec(AxEXORGCHARTLib.AxChartView chart, EXORGCHARTLib.Node n)
{
	EXORGCHARTLib.Node c = n.FirstNode;
	while (c != null)
	{
		EXORGCHARTLib.Node x = c.NextNode;
		removeRec(chart,c);
		c = x;
	}
	if ( n.Parent != null )
		chart.Nodes.Remove(n);
}

and you can call the removeRec function like follows:

removeRec(axChartView1, axChartView1.SelectNode as EXORGCHARTLib.Node);

The following VFP sample removes recursively the node all all its child nodes ( add removerec method ):

lparameters chart, n

local c
c = n.FirstNode
do While !(isnull(c))
    local x
    with c
	    x = .NextNode
	endwith
    thisform.removerec(chart, c)
    c = x
enddo
If !(isnull(n.Parent))
    chart.Nodes.Remove(n)
EndIf