Run Class
Represents a region of text with a common set of properties.
- Inheritance:
- System.ObjectRun
Remarks
Run is an Inline element used to insert textual content to a document.
Text property holds a text contained in the Run instance.
Run can be formatted directly using the CharacterFormat property or, indirectly, using a CharacterStyle class. For more information, see character formatting example.
Constructors
Run(DocumentModel)
Parameters
document
- DocumentModel
The owner document.
Run(DocumentModel, String)
Initializes a new instance of the Run class with specified text.
public Run(DocumentModel document, string text)
Public Sub New(document As DocumentModel, text As String)
Parameters
document
- DocumentModel
The owner document.
text
- System.String
The text for this Run instance.
Properties
CharacterFormat
Gets or sets the character format.
public CharacterFormat CharacterFormat { get; set; }
Public Property CharacterFormat As CharacterFormat
Property Value
The character format.
Remarks
This property is defined as direct formatting, since it is directly applied to the run and supersede any formatting from styles.
note
If Text is System.String.Empty, then Run and its CharacterFormat won't be saved to DOCX.
In that case, if Run is the last or the only element in the parent Paragraph, use CharacterFormatForParagraphMarkParagraph.CharacterFormatForParagraphMark
of the parent paragraph to save character (font) formatting to DOCX.For more information about paragraph formatting, see character formatting example.
CharacterFormatRevision
Gets or sets the revision of the format of this run. This property contains the format which was applied to this run before the revision.
public CharacterFormatRevision CharacterFormatRevision { get; set; }
Public Property CharacterFormatRevision As CharacterFormatRevision
Property Value
The revision of the format of this run.
Remarks
The revision is internally stored as a member of CharacterFormat. Using set property on CharacterFormat overrides this revision.
Document
Gets the owner document.
public override DocumentModel Document { get; }
Public Overrides ReadOnly Property Document As DocumentModel
Property Value
The owner document.
Overrides
ElementType
Gets the ElementType of this Element instance.
public override ElementType ElementType { get; }
Public Overrides ReadOnly Property ElementType As ElementType
Property Value
The ElementType of this Element instance.
Overrides
Text
Gets or sets the text of this Run instance.
Property Value
- System.String
The text of this Run instance.
Remarks
Text should not contain special characters like '\n', '\r', '\t', '\v' and '\f'. If it does, System.InvalidOperationException will be thrown. To add line breaks, page breaks, column breaks and tabs, use SpecialCharacter element.
Methods
Clone()
Clones this Run instance.
Returns
Remarks
Document content element instance can exist only in a one place in the document.
If you want to insert document content element into some other part of the same document, then clone the element and insert its clone.
If you want to insert document content element into another document, then you should first import it into another document with Import<T>(T, Boolean, Boolean) method and then insert the imported element.
For more information, see cloning example.
Inherited Properties
Content | Gets the content of the current Element. (Inherited from Element) |
Parent | Gets the parent of this Element instance. (Inherited from Element) |
ParentCollection | Gets the InlineCollection that contains this Inline instance. (Inherited from Inline) |
Revision | Gets or sets the revision information for the inline. (Inherited from Inline) |
Inherited Methods
Clone(System.Boolean) | Clones this Inline instance. (Inherited from Inline) |
GetChildElements(System.Boolean) | Gets the child elements. (Inherited from Element) |
GetChildElements(System.Boolean, ElementType[]) | Gets the child elements filtered by ElementType. (Inherited from Element) |
GetParentElements() | Gets the parent elements. (Inherited from Element) |
GetParentElements(ElementType[]) | Gets the parent elements. (Inherited from Element) |