DocumentLayout.GetElement<T>(DocumentPosition) Method
Returns the layout element of the type designated by the specified generic type parameter which relates to the specified position in the document model.
Namespace: DevExpress.XtraRichEdit.API.Layout
Assembly: DevExpress.RichEdit.v24.2.Core.dll
NuGet Package: DevExpress.RichEdit.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
position | DocumentPosition | A DocumentPosition object that specifies the position in the document model. |
Type Parameters
Name | Description |
---|---|
T |
|
Returns
Type | Description |
---|---|
T | The layout element of the type designated by the specified generic type parameter. |
Remarks
The DocumentLayout object returns information about visible elements only. If the passed DocumentPosition is hidden, the GetElement method returns null.
Example
This code snippet checks whether the first table in the document is located on the second page.
DevExpress.XtraRichEdit.API.Native.Table table = richEditControl1.Document.Tables.First;
if (table != null)
{
// Obtain the layout element related to the table.
LayoutTable ltable = richEditControl1.DocumentLayout.GetElement<LayoutTable>(table.Range.Start);
// Obtain zero-based page index of the page containing the layout element.
int pageIndex = this.richEditControl1.DocumentLayout.GetPageIndex(ltable);
// Check whether the layout element is located at the second page.
string s = "Layout verified.";
if (pageIndex != 1)
s = "The first table is not on the page 2. Review pagination.";
MessageBox.Show(s, "Check Layout", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetElement<T>(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.