event BeforeExpandNode (Node as Node, ByRef Cancel as Variant)
Occurs when a node is about to be expanded or collapsed.

TypeDescription
Node as Node A Node object being expanded or collapsed.
Cancel as Variant (By Reference) A boolean expression that indicates whether the operation is canceled or not.
Use the BeforeExpandNode event to notify your application that the user is about to expand or collapse a node. Use the Expanded property to expand or collapse a node. Use the HasChilds property to display expanding/collapsing buttons for a node to build your virtual tree. You can use the BeforeExpandNode event to cancel expanding specified nodes.

Syntax for BeforeExpandNode event, /NET version, on:

private void BeforeExpandNode(object sender,exontrol.EXMLGRIDLib.Node Node,ref object Cancel)
{
}

Private Sub BeforeExpandNode(ByVal sender As System.Object,ByVal Node As exontrol.EXMLGRIDLib.Node,ByRef Cancel As Object) Handles BeforeExpandNode
End Sub

Syntax for BeforeExpandNode event, /COM version, on:

private void BeforeExpandNode(object sender, AxEXMLGRIDLib._IXMLGridEvents_BeforeExpandNodeEvent e)
{
}

void OnBeforeExpandNode(LPDISPATCH Node,VARIANT FAR* Cancel)
{
}

void __fastcall BeforeExpandNode(TObject *Sender,Exmlgridlib_tlb::INode *Node,Variant * Cancel)
{
}

procedure BeforeExpandNode(ASender: TObject; Node : INode;var Cancel : OleVariant);
begin
end;

procedure BeforeExpandNode(sender: System.Object; e: AxEXMLGRIDLib._IXMLGridEvents_BeforeExpandNodeEvent);
begin
end;

begin event BeforeExpandNode(oleobject Node,any Cancel)
end event BeforeExpandNode

Private Sub BeforeExpandNode(ByVal sender As System.Object, ByVal e As AxEXMLGRIDLib._IXMLGridEvents_BeforeExpandNodeEvent) Handles BeforeExpandNode
End Sub

Private Sub BeforeExpandNode(ByVal Node As EXMLGRIDLibCtl.INode,Cancel As Variant)
End Sub

Private Sub BeforeExpandNode(ByVal Node As Object,Cancel As Variant)
End Sub

LPARAMETERS Node,Cancel

PROCEDURE OnBeforeExpandNode(oXMLGrid,Node,Cancel)
RETURN

Syntax for BeforeExpandNode event, /COM version (others), on:

<SCRIPT EVENT="BeforeExpandNode(Node,Cancel)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function BeforeExpandNode(Node,Cancel)
End Function
</SCRIPT>

Procedure OnComBeforeExpandNode Variant llNode Variant llCancel
	Forward Send OnComBeforeExpandNode llNode llCancel
End_Procedure

METHOD OCX_BeforeExpandNode(Node,Cancel) CLASS MainDialog
RETURN NIL

void onEvent_BeforeExpandNode(COM _Node,COMVariant /*variant*/ _Cancel)
{
}

function BeforeExpandNode as v (Node as OLE::Exontrol.XMLGrid.1::INode,Cancel as A)
end function

function nativeObject_BeforeExpandNode(Node,Cancel)
return

The following VB sample adds new child nodes to the node that's about to be expanded:

Private Sub XMLGrid1_BeforeExpandNode(ByVal Node As EXMLGRIDLibCtl.INode, Cancel As Variant)
    If Not Node.Expanded Then
        With Node.Nodes
            With .Add("New Node")
                .HasChilds = True
            End With
        End With
    End If
End Sub 

The following C++ sample adds new child nodes to the node that's about to be expanded:

#include "Node.h"
#include "Nodes.h"
void OnBeforeExpandNodeXmlgrid1(LPDISPATCH Node, VARIANT FAR* Cancel) 
{
	if ( IsWindow( m_xmlgrid.m_hWnd) )
	{
		CNode node( Node ); node.m_bAutoRelease = FALSE;
		if ( !node.GetExpanded() )
		{
			COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
			CNode newNode = node.GetNodes().Add( "New Node", vtMissing, vtMissing );
			newNode.SetHasChilds( TRUE );
		}
	}
}

The following VB.NET sample adds new child nodes to the node that's about to be expanded:

Private Sub AxXMLGrid1_BeforeExpandNode(ByVal sender As Object, ByVal e As AxEXMLGRIDLib._IXMLGridEvents_BeforeExpandNodeEvent) Handles AxXMLGrid1.BeforeExpandNode
    If Not e.node.Expanded Then
        With e.node.Nodes
            With .Add("New Node")
                .HasChilds = True
            End With
        End With
    End If
End Sub

The following C# sample adds new child nodes to the node that's about to be expanded:

private void axXMLGrid1_BeforeExpandNode(object sender, AxEXMLGRIDLib._IXMLGridEvents_BeforeExpandNodeEvent e)
{
	if (!e.node.Expanded)
	{
		EXMLGRIDLib.Nodes nodes = e.node.Nodes;
		nodes.Add( "New Node", null, null ).HasChilds = true;
	}
}

The following VFP sample adds new child nodes to the node that's about to be expanded:

*** ActiveX Control Event ***
LPARAMETERS node, cancel

with node
	If !.Expanded Then
	    With .Nodes
	        With .Add("New Node")
	            .HasChilds = .t.
	        EndWith
	    EndWith
	EndIf
endwith