Class DocumentAdv
Represents the root element of the rich text contents in a SfRichTextBoxAdv control
Implements
Namespace: Syncfusion.UI.Xaml.RichTextBoxAdv
Assembly: Syncfusion.SfRichTextBoxAdv.UWP.dll
Syntax
public class DocumentAdv : CompositeNode, INode
Examples
The following code example demonstrates how to define the document in SfRichTextBoxAdv control.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv">
<RichTextBoxAdv:DocumentAdv>
<RichTextBoxAdv:SectionAdv>
<RichTextBoxAdv:ParagraphAdv>
<RichTextBoxAdv:SpanAdv>Hello World.</RichTextBoxAdv:SpanAdv>
</RichTextBoxAdv:ParagraphAdv>
</RichTextBoxAdv:SectionAdv>
</RichTextBoxAdv:DocumentAdv>
</RichTextBoxAdv:SfRichTextBoxAdv>
// Defines the control.
SfRichTextBoxAdv richTextBoxAdv = new SfRichTextBoxAdv();
DocumentAdv documentAdv = new DocumentAdv();
SectionAdv sectionAdv = new SectionAdv();
ParagraphAdv paragraphAdv = new ParagraphAdv();
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world.";
paragraphAdv.Inlines.Add(spanAdv);
sectionAdv.Blocks.Add(paragraphAdv);
documentAdv.Sections.Add(sectionAdv);
// Defines the document for SfRichTextBoxAdv control.
richTextBoxAdv.Document = documentAdv;
' Defines the control.
Dim richTextBoxAdv As New SfRichTextBoxAdv()
Dim documentAdv As New DocumentAdv()
Dim sectionAdv As New SectionAdv()
Dim paragraphAdv As New ParagraphAdv()
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world."
paragraphAdv.Inlines.Add(spanAdv)
sectionAdv.Blocks.Add(paragraphAdv)
documentAdv.Sections.Add(sectionAdv)
' Defines the document for SfRichTextBoxAdv control.
richTextBoxAdv.Document = documentAdv
Constructors
DocumentAdv()
Initializes a new instance of the DocumentAdv class.
Declaration
public DocumentAdv()
Fields
DefaultTabWidthProperty
Identifies the DefaultTabWidth dependency property.
Declaration
public static readonly DependencyProperty DefaultTabWidthProperty
Field Value
Type | Description |
---|---|
Windows.UI.Xaml.DependencyProperty | The identifier for the DefaultTabWidth dependency property. |
Properties
AbstractLists
Gets the AbstractListAdvCollection of the DocumentAdv.
Declaration
public AbstractListAdvCollection AbstractLists { get; }
Property Value
Type | Description |
---|---|
AbstractListAdvCollection | The AbstractListAdvCollection of the DocumentAdv. |
Examples
The following code example demonstrates how to define the abstract lists.
<RichTextBoxAdv:DocumentAdv>
<RichTextBoxAdv:DocumentAdv.AbstractLists>
<RichTextBoxAdv:AbstractListAdv AbstractListId="6">
<RichTextBoxAdv:ListLevelAdv ListLevelPattern="Number" NumberFormat="(%1.)" StartAt="1" FollowCharacter="Tab">
<RichTextBoxAdv:ListLevelAdv.ParagraphFormat>
<RichTextBoxAdv:ParagraphFormat LeftIndent="48" FirstLineIndent="-24" />
</RichTextBoxAdv:ListLevelAdv.ParagraphFormat>
</RichTextBoxAdv:ListLevelAdv>
</RichTextBoxAdv:AbstractListAdv>
<!-- Any number of abstract lists can be added.-->
</RichTextBoxAdv:DocumentAdv.AbstractLists>
<RichTextBoxAdv:DocumentAdv.Lists>
<RichTextBoxAdv:ListAdv ListId="4" AbstractListId="6" />
<!-- Any number of lists can be added.-->
</RichTextBoxAdv:DocumentAdv.Lists>
<RichTextBoxAdv:SectionAdv>
<RichTextBoxAdv:ParagraphAdv>
<RichTextBoxAdv:ParagraphAdv.ParagraphFormat>
<RichTextBoxAdv:ParagraphFormat>
<RichTextBoxAdv:ParagraphFormat.ListFormat>
<RichTextBoxAdv:ListFormat ListId="4" ListLevelNumber="0" />
</RichTextBoxAdv:ParagraphFormat.ListFormat>
</RichTextBoxAdv:ParagraphFormat>
</RichTextBoxAdv:ParagraphAdv.ParagraphFormat>
<RichTextBoxAdv:SpanAdv>Hello World.</RichTextBoxAdv:SpanAdv>
</RichTextBoxAdv:ParagraphAdv>
</RichTextBoxAdv:SectionAdv>
</RichTextBoxAdv:DocumentAdv>
// Defines the document.
DocumentAdv documentAdv = new DocumentAdv();
// Initializes an abstract list.
AbstractListAdv abstractListAdv = new AbstractListAdv();
// Defines the id for abstract list.
abstractListAdv.AbstractListId = 6;
// Initializes a list level.
ListLevelAdv listLevel = new ListLevelAdv(abstractListAdv);
listLevel.ListLevelPattern = ListLevelPattern.Number;
listLevel.NumberFormat = "(%1.)";
listLevel.StartAt = 1;
listLevel.FollowCharacter = FollowCharacterType.Tab;
listLevel.ParagraphFormat = new ParagraphFormat(listLevel);
listLevel.ParagraphFormat.LeftIndent = 48;
listLevel.ParagraphFormat.FirstLineIndent = -24;
// Adds the list level to the abstract list. Upto nine list levels can be added.
abstractListAdv.Levels.Add(listLevel);
documentAdv.AbstractLists.Add(abstractListAdv);
// Add any number of abstract lists here.
ListAdv listAdv = new ListAdv();
listAdv.ListId = 4;
listAdv.AbstractListId = abstractListAdv.AbstractListId;
documentAdv.Lists.Add(listAdv);
// Add any number of lists here.
SectionAdv sectionAdv = new SectionAdv();
ParagraphAdv paragraphAdv = new ParagraphAdv();
paragraphAdv.ParagraphFormat.ListFormat = new ListFormat();
paragraphAdv.ParagraphFormat.ListFormat.ListId = 4;
paragraphAdv.ParagraphFormat.ListFormat.ListLevelNumber = 0;
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world.";
paragraphAdv.Inlines.Add(spanAdv);
sectionAdv.Blocks.Add(paragraphAdv);
documentAdv.Sections.Add(sectionAdv);
' Defines the document.
Dim documentAdv As New DocumentAdv()
' Initializes an abstract list.
Dim abstractListAdv As New AbstractListAdv()
' Defines the id for abstract list.
abstractListAdv.AbstractListId = 6
' Initializes a list level.
Dim listLevel As New ListLevelAdv(abstractListAdv)
listLevel.ListLevelPattern = ListLevelPattern.Number
listLevel.NumberFormat = "(%1.)"
listLevel.StartAt = 1
listLevel.FollowCharacter = FollowCharacterType.Tab
listLevel.ParagraphFormat = New ParagraphFormat(listLevel)
listLevel.ParagraphFormat.LeftIndent = 48
listLevel.ParagraphFormat.FirstLineIndent = -24
' Adds the list level to the abstract list. Upto nine list levels can be added.
abstractListAdv.Levels.Add(listLevel)
documentAdv.AbstractLists.Add(abstractListAdv)
' Add any number of abstract lists here.
Dim listAdv As New ListAdv()
listAdv.ListId = 4
listAdv.AbstractListId = abstractListAdv.AbstractListId
document.Lists.Add(listAdv)
' Add any number of lists here.
Dim sectionAdv As New SectionAdv()
Dim paragraphAdv As New ParagraphAdv()
paragraphAdv.ParagraphFormat.ListFormat = New ListFormat()
paragraphAdv.ParagraphFormat.ListFormat.ListId = 4
paragraphAdv.ParagraphFormat.ListFormat.ListLevelNumber = 0
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world."
paragraphAdv.Inlines.Add(spanAdv)
sectionAdv.Blocks.Add(paragraphAdv)
documentAdv.Sections.Add(sectionAdv)
Background
Gets the Background object that represents the background effects of the document. Read-only
Declaration
public Background Background { get; set; }
Property Value
Type |
---|
Background |
CharacterFormat
Gets or sets the CharacterFormat of the DocumentAdv.
Declaration
public CharacterFormat CharacterFormat { get; set; }
Property Value
Type | Description |
---|---|
CharacterFormat | The CharacterFormat of the DocumentAdv. |
Examples
The following code example demonstrates how to define the character format.
<RichTextBoxAdv:DocumentAdv>
<RichTextBoxAdv:DocumentAdv.CharacterFormat>
<RichTextBoxAdv:CharacterFormat Italic="True"/>
</RichTextBoxAdv:DocumentAdv.CharacterFormat>
<RichTextBoxAdv:SectionAdv>
<RichTextBoxAdv:ParagraphAdv>
<RichTextBoxAdv:SpanAdv>Hello World.</RichTextBoxAdv:SpanAdv>
</RichTextBoxAdv:ParagraphAdv>
</RichTextBoxAdv:SectionAdv>
</RichTextBoxAdv:DocumentAdv>
// Defines the document.
DocumentAdv documentAdv = new DocumentAdv();
documentAdv.CharacterFormat = new CharacterFormat();
documentAdv.CharacterFormat.Italic = true;
SectionAdv sectionAdv = new SectionAdv();
ParagraphAdv paragraphAdv = new ParagraphAdv();
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world.";
paragraphAdv.Inlines.Add(spanAdv);
sectionAdv.Blocks.Add(paragraphAdv);
documentAdv.Sections.Add(sectionAdv);
' Defines the document.
Dim documentAdv As New DocumentAdv()
documentAdv.CharacterFormat = New CharacterFormat()
documentAdv.CharacterFormat.Italic = True
Dim sectionAdv As New SectionAdv()
Dim paragraphAdv As New ParagraphAdv()
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world."
paragraphAdv.Inlines.Add(spanAdv)
sectionAdv.Blocks.Add(paragraphAdv)
documentAdv.Sections.Add(sectionAdv)
DefaultTabWidth
Gets or sets the default tab width of the DocumentAdv.
Declaration
public double DefaultTabWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The default tab width of the DocumentAdv. |
Examples
The following code example demonstrates how to define the default tab width.
<RichTextBoxAdv:DocumentAdv DefaultTabWidth="96">
<RichTextBoxAdv:SectionAdv>
<RichTextBoxAdv:ParagraphAdv>
<RichTextBoxAdv:SpanAdv>Hello World.</RichTextBoxAdv:SpanAdv>
</RichTextBoxAdv:ParagraphAdv>
</RichTextBoxAdv:SectionAdv>
</RichTextBoxAdv:DocumentAdv>
// Defines the document.
DocumentAdv documentAdv = new DocumentAdv();
documentAdv.DefaultTabWidth = 96;
SectionAdv sectionAdv = new SectionAdv();
ParagraphAdv paragraphAdv = new ParagraphAdv();
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world.";
paragraphAdv.Inlines.Add(spanAdv);
sectionAdv.Blocks.Add(paragraphAdv);
documentAdv.Sections.Add(sectionAdv);
' Defines the document.
Dim documentAdv As New DocumentAdv()
documentAdv.DefaultTabWidth = 96
Dim sectionAdv As New SectionAdv()
Dim paragraphAdv As New ParagraphAdv()
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world."
paragraphAdv.Inlines.Add(spanAdv)
sectionAdv.Blocks.Add(paragraphAdv)
documentAdv.Sections.Add(sectionAdv)
DocumentEnd
Gets the end TextPosition of the DocumentAdv.
Declaration
public TextPosition DocumentEnd { get; }
Property Value
Type | Description |
---|---|
TextPosition | The end TextPosition of the DocumentAdv. |
DocumentStart
Gets the start TextPosition of the DocumentAdv.
Declaration
public TextPosition DocumentStart { get; }
Property Value
Type | Description |
---|---|
TextPosition | The start TextPosition of the DocumentAdv. |
Lists
Gets the ListAdvCollection of the DocumentAdv.
Declaration
public ListAdvCollection Lists { get; }
Property Value
Type | Description |
---|---|
ListAdvCollection | The ListAdvCollection of the DocumentAdv. |
Examples
The following code example demonstrates how to define the lists.
<RichTextBoxAdv:DocumentAdv>
<RichTextBoxAdv:DocumentAdv.AbstractLists>
<RichTextBoxAdv:AbstractListAdv AbstractListId="6">
<RichTextBoxAdv:ListLevelAdv ListLevelPattern="Number" NumberFormat="(%1.)" StartAt="1" FollowCharacter="Tab">
<RichTextBoxAdv:ListLevelAdv.ParagraphFormat>
<RichTextBoxAdv:ParagraphFormat LeftIndent="48" FirstLineIndent="-24" />
</RichTextBoxAdv:ListLevelAdv.ParagraphFormat>
</RichTextBoxAdv:ListLevelAdv>
</RichTextBoxAdv:AbstractListAdv>
<!-- Any number of abstract lists can be added.-->
</RichTextBoxAdv:DocumentAdv.AbstractLists>
<RichTextBoxAdv:DocumentAdv.Lists>
<RichTextBoxAdv:ListAdv ListId="4" AbstractListId="6" />
<!-- Any number of lists can be added.-->
</RichTextBoxAdv:DocumentAdv.Lists>
<RichTextBoxAdv:SectionAdv>
<RichTextBoxAdv:ParagraphAdv>
<RichTextBoxAdv:ParagraphAdv.ParagraphFormat>
<RichTextBoxAdv:ParagraphFormat>
<RichTextBoxAdv:ParagraphFormat.ListFormat>
<RichTextBoxAdv:ListFormat ListId="4" ListLevelNumber="0" />
</RichTextBoxAdv:ParagraphFormat.ListFormat>
</RichTextBoxAdv:ParagraphFormat>
</RichTextBoxAdv:ParagraphAdv.ParagraphFormat>
<RichTextBoxAdv:SpanAdv>Hello World.</RichTextBoxAdv:SpanAdv>
</RichTextBoxAdv:ParagraphAdv>
</RichTextBoxAdv:SectionAdv>
</RichTextBoxAdv:DocumentAdv>
// Defines the document.
DocumentAdv documentAdv = new DocumentAdv();
// Initializes an abstract list.
AbstractListAdv abstractListAdv = new AbstractListAdv();
// Defines the id for abstract list.
abstractListAdv.AbstractListId = 6;
// Initializes a list level.
ListLevelAdv listLevel = new ListLevelAdv(abstractListAdv);
listLevel.ListLevelPattern = ListLevelPattern.Number;
listLevel.NumberFormat = "(%1.)";
listLevel.StartAt = 1;
listLevel.FollowCharacter = FollowCharacterType.Tab;
listLevel.ParagraphFormat = new ParagraphFormat(listLevel);
listLevel.ParagraphFormat.LeftIndent = 48;
listLevel.ParagraphFormat.FirstLineIndent = -24;
// Adds the list level to the abstract list. Upto nine list levels can be added.
abstractListAdv.Levels.Add(listLevel);
documentAdv.AbstractLists.Add(abstractListAdv);
// Add any number of abstract lists here.
ListAdv listAdv = new ListAdv();
listAdv.ListId = 4;
listAdv.AbstractListId = abstractListAdv.AbstractListId;
documentAdv.Lists.Add(listAdv);
// Add any number of lists here.
SectionAdv sectionAdv = new SectionAdv();
ParagraphAdv paragraphAdv = new ParagraphAdv();
paragraphAdv.ParagraphFormat.ListFormat = new ListFormat();
paragraphAdv.ParagraphFormat.ListFormat.ListId = 4;
paragraphAdv.ParagraphFormat.ListFormat.ListLevelNumber = 0;
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world.";
paragraphAdv.Inlines.Add(spanAdv);
sectionAdv.Blocks.Add(paragraphAdv);
documentAdv.Sections.Add(sectionAdv);
' Defines the document.
Dim documentAdv As New DocumentAdv()
' Initializes an abstract list.
Dim abstractListAdv As New AbstractListAdv()
' Defines the id for abstract list.
abstractListAdv.AbstractListId = 6
' Initializes a list level.
Dim listLevel As New ListLevelAdv(abstractListAdv)
listLevel.ListLevelPattern = ListLevelPattern.Number
listLevel.NumberFormat = "(%1.)"
listLevel.StartAt = 1
listLevel.FollowCharacter = FollowCharacterType.Tab
listLevel.ParagraphFormat = New ParagraphFormat(listLevel)
listLevel.ParagraphFormat.LeftIndent = 48
listLevel.ParagraphFormat.FirstLineIndent = -24
' Adds the list level to the abstract list. Upto nine list levels can be added.
abstractListAdv.Levels.Add(listLevel)
documentAdv.AbstractLists.Add(abstractListAdv)
' Add any number of abstract lists here.
Dim listAdv As New ListAdv()
listAdv.ListId = 4
listAdv.AbstractListId = abstractListAdv.AbstractListId
document.Lists.Add(listAdv)
' Add any number of lists here.
Dim sectionAdv As New SectionAdv()
Dim paragraphAdv As New ParagraphAdv()
paragraphAdv.ParagraphFormat.ListFormat = New ListFormat()
paragraphAdv.ParagraphFormat.ListFormat.ListId = 4
paragraphAdv.ParagraphFormat.ListFormat.ListLevelNumber = 0
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world."
paragraphAdv.Inlines.Add(spanAdv)
sectionAdv.Blocks.Add(paragraphAdv)
documentAdv.Sections.Add(sectionAdv)
OwnerControl
Gets the SfRichTextBoxAdv instance associated with the DocumentAdv.
Declaration
public SfRichTextBoxAdv OwnerControl { get; }
Property Value
Type | Description |
---|---|
SfRichTextBoxAdv | The SfRichTextBoxAdv instance associated with the DocumentAdv. |
ParagraphFormat
Gets or sets the ParagraphFormat of the DocumentAdv.
Declaration
public ParagraphFormat ParagraphFormat { get; set; }
Property Value
Type | Description |
---|---|
ParagraphFormat | The ParagraphFormat of the DocumentAdv. |
Examples
The following code example demonstrates how to define the paragraph format.
<RichTextBoxAdv:DocumentAdv>
<RichTextBoxAdv:DocumentAdv.ParagraphFormat>
<RichTextBoxAdv:ParagraphFormat FirstLineIndent="48"/>
</RichTextBoxAdv:DocumentAdv.ParagraphFormat>
<RichTextBoxAdv:SectionAdv>
<RichTextBoxAdv:ParagraphAdv>
<RichTextBoxAdv:SpanAdv>Hello World.</RichTextBoxAdv:SpanAdv>
</RichTextBoxAdv:ParagraphAdv>
</RichTextBoxAdv:SectionAdv>
</RichTextBoxAdv:DocumentAdv>
// Defines the document.
DocumentAdv documentAdv = new DocumentAdv();
documentAdv.ParagraphFormat = new ParagraphFormat();
documentAdv.ParagraphFormat.FirstLineIndent = 48;
SectionAdv sectionAdv = new SectionAdv();
ParagraphAdv paragraphAdv = new ParagraphAdv();
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world.";
paragraphAdv.Inlines.Add(spanAdv);
sectionAdv.Blocks.Add(paragraphAdv);
documentAdv.Sections.Add(sectionAdv);
' Defines the document.
Dim documentAdv As New DocumentAdv()
documentAdv.ParagraphFormat = New ParagraphFormat()
documentAdv.ParagraphFormat.FirstLineIndent = 48
Dim sectionAdv As New SectionAdv()
Dim paragraphAdv As New ParagraphAdv()
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world."
paragraphAdv.Inlines.Add(spanAdv)
sectionAdv.Blocks.Add(paragraphAdv)
documentAdv.Sections.Add(sectionAdv)
Sections
Gets the SectionAdvCollection of the DocumentAdv.
Declaration
public SectionAdvCollection Sections { get; }
Property Value
Type | Description |
---|---|
SectionAdvCollection | The SectionAdvCollection of the DocumentAdv. |
Examples
The following code example demonstrates how to define the sections.
<RichTextBoxAdv:DocumentAdv>
<RichTextBoxAdv:SectionAdv>
<RichTextBoxAdv:ParagraphAdv>
<RichTextBoxAdv:SpanAdv>Hello World.</RichTextBoxAdv:SpanAdv>
</RichTextBoxAdv:ParagraphAdv>
</RichTextBoxAdv:SectionAdv>
</RichTextBoxAdv:DocumentAdv>
// Defines the document.
DocumentAdv documentAdv = new DocumentAdv();
SectionAdv sectionAdv = new SectionAdv();
ParagraphAdv paragraphAdv = new ParagraphAdv();
SpanAdv spanAdv = new SpanAdv();
spanAdv.Text = "Hello world.";
paragraphAdv.Inlines.Add(spanAdv);
sectionAdv.Blocks.Add(paragraphAdv);
documentAdv.Sections.Add(sectionAdv);
// You can add any number of sections.
' Defines the document.
Dim documentAdv As New DocumentAdv()
Dim sectionAdv As New SectionAdv()
Dim paragraphAdv As New ParagraphAdv()
Dim spanAdv As New SpanAdv()
spanAdv.Text = "Hello world."
paragraphAdv.Inlines.Add(spanAdv)
sectionAdv.Blocks.Add(paragraphAdv)
documentAdv.Sections.Add(sectionAdv)
' You can add any number of sections.
Styles
Declaration
public StyleCollection Styles { get; }
Property Value
Type |
---|
StyleCollection |
Methods
GetTextPosition(ParagraphAdv, Double)
Gets the text position at the specified offset
in the specified ParagraphAdv.
Declaration
public TextPosition GetTextPosition(ParagraphAdv paragraphAdv, double offset)
Parameters
Type | Name | Description |
---|---|---|
ParagraphAdv | paragraphAdv | The ParagraphAdv in the DocumentAdv. |
System.Double | offset | The offset in the ParagraphAdv. |
Returns
Type | Description |
---|---|
TextPosition | Returns the TextPosition instance at the specified |
Examples
The following code example demonstrates how to get text position by specifying the paragraph and the corresponding offset.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void GetDocumentTextPositions()
{
// Gets text position at offset = 24 in a paragraph added to the section.
SectionAdv sectionAdv = richTextBoxAdv.Document.Sections[0];
ParagraphAdv sectionParagraph = sectionAdv.Blocks[0] as ParagraphAdv;
TextPosition positionAtSectionParagraph = richTextBoxAdv.Document.GetTextPosition(sectionParagraph, 24);
// Gets the text position at offset = 12 in a paragraph added to the table cell.
TableAdv tableAdv = sectionAdv.Blocks[2] as TableAdv;
ParagraphAdv cellParagraph = tableAdv.Rows[1].Cells[1].Blocks[2] as ParagraphAdv;
TextPosition positionAtCellParagraph = richTextBoxAdv.Document.GetTextPosition(cellParagraph, 12);
// Gets the text position at offset = 18 in a paragraph added to the table cell.
ParagraphAdv paragraph = sectionAdv.Blocks[4] as ParagraphAdv;
CommentAdv commentAdv = paragraph.Inlines[6] as CommentAdv;
ParagraphAdv commentParagraph = commentAdv.Blocks[0] as ParagraphAdv;
TextPosition positionAtCommentParagraph = richTextBoxAdv.Document.GetTextPosition(commentParagraph, 18);
}
Private Sub GetDocumentTextPositions()
' Gets text position at offset = 24 in a paragraph added to the section.
Dim sectionAdv As SectionAdv = richTextBoxAdv.Document.Sections(0)
Dim sectionParagraph As ParagraphAdv = TryCast(sectionAdv.Blocks(0), ParagraphAdv)
Dim positionAtSectionParagraph As TextPosition = richTextBoxAdv.Document.GetTextPosition(sectionParagraph, 24)
' Gets text position at offset = 12 in a paragraph added to the table cell.
Dim tableAdv As TableAdv = TryCast(sectionAdv.Blocks(2), TableAdv)
Dim cellParagraph As ParagraphAdv = TryCast(tableAdv.Rows(1).Cells(1).Blocks(2), ParagraphAdv)
Dim positionAtCellParagraph As TextPosition = richTextBoxAdv.Document.GetTextPosition(cellParagraph, 12)
' Gets text position at offset = 18 in a paragraph added to the comment.
Dim paragraph As ParagraphAdv = TryCast(sectionAdv.Blocks(4), ParagraphAdv)
Dim commentAdv As CommentAdv = TryCast(paragraph.Inlines(6), CommentAdv)
Dim commentParagraph As ParagraphAdv = TryCast(commentAdv.Blocks(0), ParagraphAdv)
Dim positionAtCommentParagraph As TextPosition = richTextBoxAdv.Document.GetTextPosition(commentParagraph, 18)
End Sub
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | ParagraphAdv cannot be null. |
System.ArgumentException | Invalid paragraph. The paragraph doesn't exist in the document. |
System.ArgumentOutOfRangeException | Offset should be greater than or equal to zero and should be less than or equal to the paragraph length. |
See Also
GetTextPosition(String)
Gets the text position at the specified hierarchicalPosition
in the DocumentAdv.
Declaration
public TextPosition GetTextPosition(string hierarchicalPosition)
Parameters
Type | Name | Description |
---|---|---|
System.String | hierarchicalPosition | The hierarchical position in the DocumentAdv. The hierarchical position should be given as "section-index;block-index;offset-in-paragraph". If the ParagraphAdv is added to the SectionAdv, then it can be "section-index;paragraph-index;offset-in-paragraph". Else if added to the TableCellAdv, then it can be "section-index;table-index;row-index;cell-index;paragraph-index;offset-in-paragraph". Else if added to the CommentAdv, then it can be "section-index;paragraph-index;offset-at-which-comment-is-present;C;block-index;offset-in-paragraph". |
Returns
Type | Description |
---|---|
TextPosition | Returns TextPosition instance, if the specified |
Examples
The following code example demonstrates how to get text position in a document by specifying the hierarchical position.
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv"/>
public void GetDocumentTextPositions()
{
// Retrieves the text position at offset = 24 in a paragraph added to the section.
// Here section index is 0 and paragraph index is 0.
TextPosition positionAtSectionParagraph = richTextBoxAdv.Document.GetTextPosition("0;0;24");
// Retrieves the text position at offset = 12 in a paragraph added to the table cell.
// Here section index is 0, table index is 2, row index is 1, cell index is 1 and paragraph index is 3.
TextPosition positionAtCellParagraph = richTextBoxAdv.Document.GetTextPosition("0;2;1;3;12");
// Retrieves the text position at offset = 18 in a paragraph added to the comment.
// Here section index is 0, paragraph(containing comment) index is 1, offset of comment is 16, paragraph(in comment) index is 2.
TextPosition positionAtCommentParagraph = richTextBoxAdv.Document.GetTextPosition("0;1;16;C;2;18");
}
Private Sub GetDocumentTextPositions()
' Retrieves the text position at offset = 24 in a paragraph added to the section.
' Here section index is 0 and paragraph index is 0.
Dim positionAtSectionParagraph As TextPosition = richTextBoxAdv.Document.GetTextPosition("0;0;24")
' Retrieves the text position at offset = 12 in a paragraph added to the table cell.
' Here section index is 0, table index is 2, row index is 1, cell index is 1 and paragraph index is 3.
Dim positionAtCellParagraph As TextPosition = richTextBoxAdv.Document.GetTextPosition("0;2;1;3;12")
' Retrieves the text position at offset = 18 in a paragraph added to the comment.
' Here section index is 0, paragraph(containing comment) index is 1, offset of comment is 16, paragraph(in comment) index is 2.
Dim positionAtCommentParagraph As TextPosition = richTextBoxAdv.Document.GetTextPosition("0;1;16;C;2;18")
End Sub
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Hierarchical position cannot be null. |