New to Telerik UI for WinForms? Start a free 30-day trial

Stores layout boxes as a linked sequence with paired boundary nodes for container boxes, enabling tree traversal and edits.

Definition

Namespace:Telerik.WinForms.Documents.DocumentStructure

Assembly:Telerik.WinControls.RichTextEditor.dll

Syntax:

C#
public class DocumentStructureCollection

Inheritance: objectDocumentStructureCollection

Constructors

Initializes a document structure collection rooted at the specified layout box. Container roots receive paired boundary nodes; leaf roots are stored as a single node.

C#
public DocumentStructureCollection(LayoutBox rootBox)
Parameters:rootBoxLayoutBox

The layout box at the root of the structure.

Initializes a document structure collection rooted at the specified layout element.

C#
public DocumentStructureCollection(LayoutElement layoutElement)
Parameters:layoutElementLayoutElement

The root element, which must be a LayoutBox.

Properties

Gets the stack of layout boxes active during the current structure traversal.

C#
public BoxParentsStack EnumerationStack { get; }

Methods

Adds a child to a parent box and updates the associated document element's first-layout-box reference when needed.

C#
public void AddChild(LayoutBox parent, LayoutBox child)
Parameters:parentLayoutBox

The container that receives the child.

childLayoutBox

The box to add.

Appends a container box as the last child of the specified parent.

C#
public void AddContainerChildBefore(LayoutBox parent, LayoutBox newBox)
Parameters:parentLayoutBox

The container that receives the new child.

newBoxLayoutBox

The container box to insert.

Adds a container box and its boundary nodes as the parent's child.

C#
public void AddContainerChildBox(LayoutBox parent, LayoutBox child)
Parameters:parentLayoutBox

The container that receives the child.

childLayoutBox

The container box to add.

Inserts a container box and its complete node range after an existing sibling.

C#
public void AddContainerSiblingAfter(LayoutBox layoutBox, LayoutBox newSibling)
Parameters:layoutBoxLayoutBox

The existing sibling that precedes the insertion point.

newSiblingLayoutBox

The container box to insert.

Inserts a container box and its complete node range before an existing sibling.

C#
public void AddContainerSiblingBefore(LayoutBox layoutBox, LayoutBox newSibling)
Parameters:layoutBoxLayoutBox

The existing sibling that follows the insertion point.

newSiblingLayoutBox

The container box to insert.

Adds a leaf box immediately before the parent's closing boundary node.

C#
public void AddLeafChildBox(LayoutBox parent, LayoutBox child)
Parameters:parentLayoutBox

The container that receives the child.

childLayoutBox

The leaf box to add.

Inserts a split inline box immediately after the specified box.

C#
public void AddLeafSiblingAfter(LayoutBox layoutBox, LayoutBox newSibling)
Parameters:layoutBoxLayoutBox

The existing inline box that precedes the new box.

newSiblingLayoutBox

The inline box to insert.

Exceptions: InvalidOperationException

newSibling is not an InlineLayoutBox.

Inserts a split inline box immediately before the specified box. If both boxes represent the same document element, updates its first-layout-box reference when needed.

C#
public void AddLeafSiblingBefore(LayoutBox layoutBox, LayoutBox newSibling)
Parameters:layoutBoxLayoutBox

The existing inline box that follows the new box.

newSiblingLayoutBox

The inline box to insert.

Exceptions: InvalidOperationException

newSibling is not an InlineLayoutBox.

Inserts a sibling after the specified box, using container or leaf node handling as appropriate.

C#
public void AddSiblingAfter(LayoutBox layoutBox, LayoutBox newSibling)
Parameters:layoutBoxLayoutBox

The existing box that precedes the new sibling.

newSiblingLayoutBox

The box to insert after layoutBox.

Inserts a sibling before the specified box, using container or leaf node handling as appropriate.

C#
public void AddSiblingBefore(LayoutBox layoutBox, LayoutBox newSibling)
Parameters:layoutBoxLayoutBox

The existing box that follows the new sibling.

newSiblingLayoutBox

The box to insert before layoutBox.

Removes all direct children of the specified box and invalidates measurement up to the root.

C#
public void ClearChildren(LayoutBox layoutBoxParent)
Parameters:layoutBoxParentLayoutBox

The box whose children are removed.

Gets the number of direct child boxes; leaf boxes have a count of zero.

C#
public static int GetChildrenCount(LayoutBox box)
Parameters:boxLayoutBox

The box whose children are counted.

Returns:

int

The number of direct child boxes.

Gets the first direct child of a container box.

C#
public static LayoutBox GetFirstChild(LayoutBox box)
Parameters:boxLayoutBox

The box whose first child is requested.

Returns:

LayoutBox

The first child, or null when the box is a leaf or has no children.

Gets the last direct child of a container box.

C#
public static LayoutBox GetLastChild(LayoutBox box)
Parameters:boxLayoutBox

The box whose last child is requested.

Returns:

LayoutBox

The last child, or null when the box is a leaf or has no children.

Gets the next layout box representing the specified document element. Flow-ordered boxes use their associated-box link; other boxes search same-level siblings.

C#
public static LayoutBox GetNextAssociatedLayoutBox(LayoutBox box, DocumentElement associatedDocumentElement)
Parameters:boxLayoutBox

The box from which to continue the search.

associatedDocumentElementDocumentElement

The document element represented by the returned box.

Returns:

LayoutBox

The next associated box, or null when none is found.

Finds the next box assignable to the specified box's concrete runtime type.

C#
public static LayoutBox GetNextElementOfSameType(LayoutBox box)
Parameters:boxLayoutBox

The box whose runtime type is used for the search.

Returns:

LayoutBox

The next matching box in logical layout order, or null when none is found.

Finds the next box in logical layout order whose runtime type is assignable to the specified type.

C#
public static LayoutBox GetNextElementOfType(LayoutBox box, Type type)
Parameters:boxLayoutBox

The box from which the forward search begins.

typeType

The type used to match candidate boxes.

Returns:

LayoutBox

The next matching box, or null when none is found.

Gets the next box at the same parent level, skipping the descendants of a container box.

C#
public static LayoutBox GetNextSibling(LayoutBox box)
Parameters:boxLayoutBox

The box whose next sibling is requested.

Returns:

LayoutBox

The next sibling, or null when there is none.

Gets the next same-type sibling in the owner scope; the sibling or its parent may represent that document element. Inline boxes are searched by the shared InlineLayoutBox type.

C#
public static LayoutBox GetNextSiblingForDocumentElement(LayoutBox box, DocumentElement owner)
Parameters:boxLayoutBox

The box whose next sibling is requested.

ownerDocumentElement

The document element that constrains the search.

Returns:

LayoutBox

The matching next sibling, or null when none is found.

Finds the next box at the same logical level, accounting for container boundaries in the linked structure.

C#
public static LayoutBox GetNextSiblingForDocumentElementOnSameLevel(LayoutBox box, DocumentElement owner)
Parameters:boxLayoutBox

The box from which to search forward.

ownerDocumentElement

An optional owner checked when searching across container boundaries; a direct sibling is returned without checking it.

Returns:

LayoutBox

The next box at the same level, or null when none matches.

Gets the parent layout box by walking backward from the child's node to its enclosing container boundary.

C#
public static LayoutBox GetParent(LayoutBox child)
Parameters:childLayoutBox

The box whose parent is requested.

Returns:

LayoutBox

The parent box, or null when the box is at the root.

Finds the previous box assignable to the specified box's concrete runtime type.

C#
public static LayoutBox GetPreviousElementOfSameType(LayoutBox box)
Parameters:boxLayoutBox

The box whose runtime type is used for the search.

Returns:

LayoutBox

The previous matching box in logical layout order, or null when none is found.

Finds the previous box in logical layout order whose runtime type is assignable to the specified type.

C#
public static LayoutBox GetPreviousElementOfType(LayoutBox box, Type type)
Parameters:boxLayoutBox

The box from which the backward search begins.

typeType

The type used to match candidate boxes.

Returns:

LayoutBox

The previous matching box, or null when none is found.

Gets the previous box at the same parent level, skipping the descendants of a container box.

C#
public static LayoutBox GetPreviousSibling(LayoutBox box)
Parameters:boxLayoutBox

The box whose previous sibling is requested.

Returns:

LayoutBox

The previous sibling, or null when there is none.

Gets the previous same-type sibling in the owner scope; the sibling or its parent may represent that document element. Inline boxes are searched by the shared InlineLayoutBox type.

C#
public static LayoutBox GetPreviousSiblingForDocumentElement(LayoutBox box, DocumentElement owner)
Parameters:boxLayoutBox

The box whose previous sibling is requested.

ownerDocumentElement

The document element that constrains the search.

Returns:

LayoutBox

The matching previous sibling, or null when none is found.

Finds the previous box at the same logical level, accounting for container boundaries in the linked structure.

C#
public static LayoutBox GetPreviousSiblingForDocumentElementOnSamelevel(LayoutBox box, DocumentElement owner)
Parameters:boxLayoutBox

The box from which to search backward.

ownerDocumentElement

An optional owner checked when searching across container boundaries; a direct sibling is returned without checking it.

Returns:

LayoutBox

The previous box at the same level, or null when none matches.

Gets the root box when it is a document layout box.

C#
public DocumentLayoutBox GetRootBox()
Returns:

DocumentLayoutBox

The root DocumentLayoutBox, or null when the root has another type.

Gets whether the box is a container with at least one child.

C#
public static bool HasChildren(LayoutBox box)
Parameters:boxLayoutBox

The box to inspect.

Returns:

bool

true when the box has children; otherwise, false.

Merges compatible adjacent containers throughout the root document and invalidates the root layout.

C#
public void MergeContainers()

Merges compatible adjacent containers beginning at the specified layout box.

C#
public void MergeContainers(LayoutBox fromBox)
Parameters:fromBoxLayoutBox

The container at which merging begins.

Merges adjacent span fragments in a paragraph when their layout boxes can be combined.

C#
public void MergeLongWords(ParagraphLayoutBox paragraphLayoutBox)
Parameters:paragraphLayoutBoxParagraphLayoutBox

The paragraph whose inline boxes are examined.

Merges adjacent compatible span fragments starting at the specified inline box. When an associated element is supplied, merging is limited to spans representing that element.

C#
public void MergeLongWordsFromBox(InlineLayoutBox layoutBox, DocumentElement associatedDocumentElement)
Parameters:layoutBoxInlineLayoutBox

The inline box from which the search begins.

associatedDocumentElementDocumentElement

The document element that limits the merge, or null to process subsequent spans.

Merges the content of a table-row slice into its preceding row box and removes the slice.

C#
public void MergeTableRowBoxes(TableRowLayoutBox firstRow, TableRowLayoutBox secondRow)
Parameters:firstRowTableRowLayoutBox

The row box that receives matching cell content.

secondRowTableRowLayoutBox

The adjacent row slice whose cell content is merged.

Merges the second container box into the first, reparents its remaining children, and invalidates layout.

C#
public void MergeTwoLayoutBoxes(LayoutBox firstBox, LayoutBox secondBox, bool shouldFinalizeRemoval = true)
Parameters:firstBoxLayoutBox

The container that receives the merged content.

secondBoxLayoutBox

The container whose content is merged into firstBox.

shouldFinalizeRemovalbool

true to finalize removal of the second box's associated document element.

Removes a box and, for a container, all of its descendants from the document structure. Updates the associated document element's first-layout-box reference when necessary.

C#
public void RemoveChild(LayoutBox child)
Parameters:childLayoutBox

The box to remove.

Removes the last child entry from a container. For a container child, this implementation removes its start node and the following node, so it is safe only when that child has no descendants.

C#
public void RemoveLastChild(LayoutBox parent)
Parameters:parentLayoutBox

The container whose last child is removed.

Removes the immediate next node unless it is a container-closing boundary.

C#
public void RemoveLeafSiblingAfter(LayoutBox layoutBox)
Parameters:layoutBoxLayoutBox

The box before the node to remove.

Replaces a box's node value with a span layout box while preserving the node's position and parent. Raises the old box's structure-change notifications as it is removed.

C#
public static void ReplaceLayoutBox(LayoutBox boxWithNodeToUpdate, SpanLayoutBox newNodeValue)
Parameters:boxWithNodeToUpdateLayoutBox

The box whose node is reused.

newNodeValueSpanLayoutBox

The span layout box assigned to that node.

Splits a container at the specified child, placing that child and subsequent siblings in a new layout box. Passing null for fromLayoutBox creates an empty fragment at the end.

C#
public void SplitContainer(LayoutBox boxToSplit, LayoutBox fromLayoutBox, LayoutBox newLayoutBox)
Parameters:boxToSplitLayoutBox

The container to split.

fromLayoutBoxLayoutBox

The first child moved to the new fragment, or null to create an empty fragment.

newLayoutBoxLayoutBox

The new container that receives the fragment.

Returns a diagnostic representation of the linked layout structure, including node kinds and box indices.

C#
public override string ToString()
Returns:

string

A multiline description of the layout boxes in this collection.

Overrides: object.ToString()

In this article
DefinitionConstructorsDocumentStructureCollection(LayoutBox)DocumentStructureCollection(LayoutElement)PropertiesEnumerationStackMethodsAddChild(LayoutBox, LayoutBox)AddContainerChildBefore(LayoutBox, LayoutBox)AddContainerChildBox(LayoutBox, LayoutBox)AddContainerSiblingAfter(LayoutBox, LayoutBox)AddContainerSiblingBefore(LayoutBox, LayoutBox)AddLeafChildBox(LayoutBox, LayoutBox)AddLeafSiblingAfter(LayoutBox, LayoutBox)AddLeafSiblingBefore(LayoutBox, LayoutBox)AddSiblingAfter(LayoutBox, LayoutBox)AddSiblingBefore(LayoutBox, LayoutBox)ClearChildren(LayoutBox)GetChildrenCount(LayoutBox)GetFirstChild(LayoutBox)GetLastChild(LayoutBox)GetNextAssociatedLayoutBox(LayoutBox, DocumentElement)GetNextElementOfSameType(LayoutBox)GetNextElementOfType(LayoutBox, Type)GetNextSibling(LayoutBox)GetNextSiblingForDocumentElement(LayoutBox, DocumentElement)GetNextSiblingForDocumentElementOnSameLevel(LayoutBox, DocumentElement)GetParent(LayoutBox)GetPreviousElementOfSameType(LayoutBox)GetPreviousElementOfType(LayoutBox, Type)GetPreviousSibling(LayoutBox)GetPreviousSiblingForDocumentElement(LayoutBox, DocumentElement)GetPreviousSiblingForDocumentElementOnSamelevel(LayoutBox, DocumentElement)GetRootBox()HasChildren(LayoutBox)MergeContainers()MergeContainers(LayoutBox)MergeLongWords(ParagraphLayoutBox)MergeLongWordsFromBox(InlineLayoutBox, DocumentElement)MergeTableRowBoxes(TableRowLayoutBox, TableRowLayoutBox)MergeTwoLayoutBoxes(LayoutBox, LayoutBox, bool)RemoveChild(LayoutBox)RemoveLastChild(LayoutBox)RemoveLeafSiblingAfter(LayoutBox)ReplaceLayoutBox(LayoutBox, SpanLayoutBox)SplitContainer(LayoutBox, LayoutBox, LayoutBox)ToString()
Not finding the help you need?
Contact Support