Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

DocumentPosition Class

A position within a document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v19.1.Core.dll

Declaration

[ComVisible(true)]
public abstract class DocumentPosition :
    IComparable<DocumentPosition>

The following members accept/return DocumentPosition objects:

Library Related API Members
WinForms Controls RichEditControl.GetPositionFromPoint(PointF)
WPF Controls RichEditControl.GetPositionFromPoint(PointF)
Office File API Capture.Position
CustomMark.Position
Document.CaretPosition
DocumentRange.End
DocumentRange.Start
SubDocument.CreatePosition(Int32)

Remarks

Use the Document.CaretPosition property to get the current cursor (caret) position. The RichEditControl.GetPositionFromPoint method allows you to convert mouse coordinates to a document position.

The DocumentRange.Start and DocumentRange.End positions define a DocumentRange object.

Use the SubDocument.CreatePosition method to obtain an arbitrary position in a document. Call the DocumentPosition.ToInt method to convert a DocumentPosition object to an integer position.

The code sample below obtains a range that starts from the retrieved position:

Document document = server.Document;
document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
DocumentPosition myStart = document.CreatePosition(69);
DocumentRange myRange = document.CreateRange(myStart, 216);

The following code snippets (auto-collected from DevExpress Examples) contain references to the DocumentPosition class.

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.

Inheritance

Object
DocumentPosition
See Also