RunCollectionItem Property

Retrieves a Run at the given index.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public Run this[
	int index
] { get; }

Parameters

index
Type: SystemInt32
An index into the collection.

Property Value

Type: Run
Remarks
Remarks

The index is zero-based.

Negative indexes are allowed and indicate access from the back of the collection. For example -1 means the last item, -2 means the second before last and so on.

If index is greater than or equal to the number of items in the list, this returns a null reference.

If index is negative and its absolute value is greater than the number of items in the list, this returns a null reference.

Examples
Shows how to process revision-related properties of Inline nodes.
Document doc = new Document(MyDir + "Revision runs.docx");

// This document has 6 revisions
Assert.AreEqual(6, doc.Revisions.Count);

// The parent node of a revision is the run that the revision concerns, which is an Inline node
Run run = (Run)doc.Revisions[0].ParentNode;

// Get the parent paragraph
Paragraph firstParagraph = run.ParentParagraph;
RunCollection runs = firstParagraph.Runs;

Assert.AreEqual(6, runs.ToArray().Length);

// The text in the run at index #2 was typed after revisions were tracked, so it will count as an insert revision
// The font was changed, so it will also be a format revision
Assert.IsTrue(runs[2].IsInsertRevision);
Assert.IsTrue(runs[2].IsFormatRevision);

// If one node was moved from one place to another while changes were tracked,
// the node will be placed at the departure location as a "move to revision",
// and a "move from revision" node will be left behind at the origin, in case we want to reject changes
// Highlighting text and dragging it to another place with the mouse and cut-and-pasting (but not copy-pasting) both count as "move revisions"
// The node with the "IsMoveToRevision" flag is the arrival of the move operation, and the node with the "IsMoveFromRevision" flag is the departure point
Assert.IsTrue(runs[1].IsMoveToRevision);
Assert.IsTrue(runs[4].IsMoveFromRevision);

// If an Inline node gets deleted while changes are being tracked, it will leave behind a node with the IsDeleteRevision flag set to true until changes are accepted
Assert.IsTrue(runs[5].IsDeleteRevision);
See Also