AddChild method

The AddChild method adds a child object to the parent runtime DCO object. You can use the AddChild method to add a field to a page or add a page to a document. You can add only a child that is at the same or a lower level than this object in the hierarchy.

Syntax

VBScript
oDCO.AddChild (ObjectType as Long, ID as String, 
Placement as Long) as Object
C#
TDCOLib.DCO AddChild(int nType, string lpszID, int nIndex)

Applies to

All objects.

Arguments

nType
The type of the child object:
0=Batch
1=Document
2=Page
3=Field
4=Character
lpszID
A string with the ID of the new object. Use an empty string for character objects.
nIndex
The index of the child object relative to other child objects of the same parent. If necessary, existing child objects are moved down to accommodate a new child object.
-1: Adds the new child object to the end of the list.
0: Adds the new child object to the beginning of the list.

Returns

The child object of the specified type.

C# examples

The first example creates a field object under the parent page object. The field is added to the page data file as the last field in the list by using a value of -1.

m_oDCOField = m_oDCOPage.AddChild(3, "NewField", -1);

The second example adds a character object to the parent field object. The new character is added at the beginning of the list (0) and all existing character fields move down one position.

m_oDCOChar = m_oDCOField.AddChild(4, "", 0);
  • You cannot add a parent to a child. For example, you cannot add a page object to a field object.
  • You cannot assign an ID that is already used by another child of the same parent.