officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-readonlyparagraphcollection-dot-get-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-x29.md
Gets a paragraph which contains the specified position.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
Paragraph Get(
DocumentPosition pos
)
Function Get(
pos As DocumentPosition
) As Paragraph
| Name | Type | Description |
|---|---|---|
| pos | DocumentPosition |
A DocumentPosition for which an encompassed paragraph is obtained.
|
| Type | Description |
|---|---|
| Paragraph |
A Paragraph object.
|
The Get method returns a Paragraph object which encompasses the specified position.
Note
If you operate with a selection range, the Get method should be enclosed within a DocumentRange.BeginUpdateDocument - DocumentRange.EndUpdateDocument method pair. Otherwise, an incorrect document model might be selected, resulting in an exception “Error: specified document position or range belongs to other document or subdocument” being thrown.
The following code snippets (auto-collected from DevExpress Examples) contain references to the Get(DocumentPosition) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
int currentParagraphIndex = currentDocument.Paragraphs.ToList().IndexOf(currentDocument.Paragraphs.Get(currentDocument.CreatePosition(currentTextBlock.Range.Start)));
returnedInformation += String.Format("Paragrpah index: {0}\r\n", currentParagraphIndex + 1);
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Range.cs#L79
SubDocument doc = pos.BeginUpdateDocument();
Paragraph par = doc.Paragraphs.Get(pos);
DocumentPosition newPos = doc.CreatePosition(par.Range.End.ToInt() - 1);
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/RangeActions.cs#L79
SubDocument doc = pos.BeginUpdateDocument();
Paragraph par = doc.Paragraphs.Get(pos);
DocumentPosition newPos = doc.CreatePosition(par.Range.End.ToInt() - 1);
word-document-api-examples/CS/CodeExamples/RangeActions.cs#L93
SubDocument doc = pos.BeginUpdateDocument();
Paragraph par = doc.Paragraphs.Get(pos);
DocumentPosition newPos = doc.CreatePosition(par.Range.End.ToInt() - 1);
Dim currentParagraphIndex As Integer = currentDocument.Paragraphs.ToList().IndexOf(currentDocument.Paragraphs.Get(currentDocument.CreatePosition(currentTextBlock.Range.Start)))
returnedInformation &= String.Format("Paragrpah index: {0}" & Constants.vbCrLf, currentParagraphIndex + 1)
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Range.vb#L73
Dim doc As DevExpress.XtraRichEdit.API.Native.SubDocument = pos.BeginUpdateDocument()
Dim par As DevExpress.XtraRichEdit.API.Native.Paragraph = doc.Paragraphs.[Get](pos)
Dim newPos As DevExpress.XtraRichEdit.API.Native.DocumentPosition = doc.CreatePosition(par.Range.[End].ToInt() - 1)
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/RangeActions.vb#L71
Dim doc As SubDocument = pos.BeginUpdateDocument()
Dim par As Paragraph = doc.Paragraphs.Get(pos)
Dim newPos As DocumentPosition = doc.CreatePosition(par.Range.End.ToInt() - 1)
word-document-api-examples/VB/CodeExamples/RangeActions.vb#L83
Dim doc As DevExpress.XtraRichEdit.API.Native.SubDocument = pos.BeginUpdateDocument()
Dim par As DevExpress.XtraRichEdit.API.Native.Paragraph = doc.Paragraphs.[Get](pos)
Dim newPos As DevExpress.XtraRichEdit.API.Native.DocumentPosition = doc.CreatePosition(par.Range.[End].ToInt() - 1)
See Also
ReadOnlyParagraphCollection Interface