NodeChangingArgs class

Provides data for methods of the INodeChangingCallback interface.

public class NodeChangingArgs


Name Description
Action { get; } Gets a value indicating what type of node change event is occurring.
NewParent { get; } Gets the node’s parent that will be set after the operation completes.
Node { get; } Gets the Node that is being added or removed.
OldParent { get; } Gets the node’s parent before the operation began.


Shows how customize node changing with a callback.

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    // Set the node changing callback to custom implementation,
    // then add/remove nodes to get it to generate a log.
    HandleNodeChangingFontChanger callback = new HandleNodeChangingFontChanger();
    doc.NodeChangingCallback = callback;

    builder.Writeln("Hello world!");
    builder.Writeln("Hello again!");
    builder.InsertField(" HYPERLINK \"\" ");
    builder.InsertShape(ShapeType.Rectangle, 300, 300);



/// <summary>
/// Logs the date and time of each node insertion and removal.
/// Sets a custom font name/size for the text contents of Run nodes.
/// </summary>
public class HandleNodeChangingFontChanger : INodeChangingCallback
    void INodeChangingCallback.NodeInserted(NodeChangingArgs args)

        if (args.Node.NodeType == NodeType.Run)
            Aspose.Words.Font font = ((Run) args.Node).Font;
            mLog.Append($"\tFont:\tChanged from \"{font.Name}\" {font.Size}pt");

            font.Size = 24;
            font.Name = "Arial";

            mLog.AppendLine($" to \"{font.Name}\" {font.Size}pt");

    void INodeChangingCallback.NodeInserting(NodeChangingArgs args)
        mLog.AppendLine($"\n{DateTime.Now:dd/MM/yyyy HH:mm:ss:fff}\tNode insertion:");

    void INodeChangingCallback.NodeRemoved(NodeChangingArgs args)
        mLog.AppendLine($"\tHash code:\t{args.Node.GetHashCode()}");

    void INodeChangingCallback.NodeRemoving(NodeChangingArgs args)
        mLog.AppendLine($"\n{DateTime.Now:dd/MM/yyyy HH:mm:ss:fff}\tNode removal:");

    public string GetLog()
        return mLog.ToString();

    private readonly StringBuilder mLog = new StringBuilder();

See Also