officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-layout-dot-documentlayout-dot-getelement-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-devexpress-dot-xtrarichedit-dot-api-dot-layout-dot-layouttype-x29.md
Gets the layout element of the specified type which relates to the specified position in the document model.
Namespace : DevExpress.XtraRichEdit.API.Layout
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
public RangedLayoutElement GetElement(
DocumentPosition position,
LayoutType type
)
Public Function GetElement(
position As DocumentPosition,
type As LayoutType
) As RangedLayoutElement
| Name | Type | Description |
|---|---|---|
| position | DocumentPosition |
A DocumentPosition object that specifies the position in the document model.
| | type | LayoutType |
A LayoutType enumeration that specifies the type of the requested layout element.
|
| Type | Description |
|---|---|
| RangedLayoutElement |
A RangedLayoutElement class descendant if the specified layout type can be related to a document position; otherwise, an exception is thrown.
|
Important
If the specified layout type cannot be related to a document position (e.g. LayoutType.BookmarkStartBox, LayoutType.BookmarkEndBox), an exception is thrown.
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetElement(DocumentPosition, LayoutType) 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.
RangedLayoutElement tableCell = currentDocumentLayout.GetElement(docPosition, LayoutType.TableCell);
if(tableCell != null)
winforms-richedit-layout-api/CS/Form1.cs#L83
DocumentPosition pos = subDoc.CreatePosition(richEditControl1.Document.CaretPosition.ToInt() == 0 ? 0 : richEditControl1.Document.CaretPosition.ToInt() - 1);
LayoutPageArea pageArea = richEditControl1.DocumentLayout.GetElement(pos, LayoutType.PageArea) as LayoutPageArea;
LayoutPage page = pageArea.GetParentByType<LayoutPage>();
word-document-api-use-layout-api-to-manage-document-pages/CS/Program.cs#L50
var documentLayout = rtfProcessor.DocumentLayout;
var row = documentLayout.GetElement(pos, LayoutType.Row);
LayoutPage page = row.GetParentByType<LayoutPage>();
Dim tableCell As RangedLayoutElement = currentDocumentLayout.GetElement(docPosition, LayoutType.TableCell)
If tableCell IsNot Nothing Then
winforms-richedit-layout-api/VB/Form1.vb#L70
Dim pos As DocumentPosition = subDoc.CreatePosition(If(richEditControl1.Document.CaretPosition.ToInt() = 0, 0, richEditControl1.Document.CaretPosition.ToInt() - 1))
Dim pageArea As LayoutPageArea = TryCast(richEditControl1.DocumentLayout.GetElement(pos, LayoutType.PageArea), LayoutPageArea)
Dim page As LayoutPage = pageArea.GetParentByType(Of LayoutPage)()
word-document-api-use-layout-api-to-manage-document-pages/VB/Program.vb#L38
Dim documentLayout = rtfProcessor.DocumentLayout
Dim row = documentLayout.GetElement(pos, LayoutType.Row)
Dim page As LayoutPage = row.GetParentByType(Of LayoutPage)()
See Also