Skip to main content

RichEditControl.GetBoundsFromPosition(DocumentPosition) Method

Gets bounds of the character at the specified position.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v24.1.dll

NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.RichEdit, DevExpress.Win.TreeMap


public Rectangle GetBoundsFromPosition(
    DocumentPosition pos


Name Type Description
pos DocumentPosition

A target position.


Type Description

the area occupied by a character, or the System.Drawing.Rectangle.Empty value if the bounds could not be determined.


You can use the GetBoundsFromPosition method only for the currently visible document part. If the specified position is not displayed, the method returns a System.Drawing.Rectangle.Empty value.

The rectangle’s location and size are expressed in currently specified measurement units. Use the Document.Unit property to change the measurement units.


The following code highlights the line containing the caret. The Document.CaretPosition property determines the caret position, the RichEditControl.GetBoundsFromPosition method calculates the caret screen coordinates.

The RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.

View Example

static void richEditControl_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
    RichEditControl richEdit = sender as RichEditControl;
    DocumentPosition pos = richEdit.Document.CaretPosition;
    if(pos != null) {
        System.Drawing.Rectangle rect = DevExpress.Office.Utils.Units.DocumentsToPixels(

        Section firstSection = richEdit.Document.Sections[0];
        int pageWidth = Convert.ToInt32(firstSection.Page.Width - firstSection.Margins.Left - firstSection.Margins.Right);
            new System.Drawing.Point(0, rect.Bottom), 
            new System.Drawing.Point(pageWidth, rect.Bottom));

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


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.

See Also