.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Box

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.v21.2.Core.dll

Declaration

public T GetElement<T>(
    DocumentPosition position
)
    where T : RangedLayoutElement

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);
}
See Also