Skip to main content
A newer version of this page is available. .

RichEditControl.ScrollToCaret(Single) Method

Scrolls the document so that the caret position is displayed at the specified relative vertical offset.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v19.1.dll

Declaration

public void ScrollToCaret(
    float relativeVerticalPosition
)

Parameters

Name Type Description
relativeVerticalPosition Single

A number specifying the relative vertical offset. Must be within the range 0.0 - 1.0

Remarks

The ScrollToCaret method allows you to scroll the document to display the caret position at the specified relative offset from the top of the control. An offset equal to zero means that the row containing caret will be the first visible row in the document; offset value 1.0 specifies that the mentioned row will be the last visible row.

To get the caret position programmatically, use the Document.CaretPosition property.

Example

The following code loads a document and scrolls to its end. The current RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.

static void buttonCustomAction_ItemClick_ScrollToCaretMethod(object sender, ItemClickEventArgs e) {
    RichEditControl richEdit = e.Item.Tag as RichEditControl;
    richEdit.LoadDocument("Documents\\MultiPageDocument.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
    richEdit.Document.CaretPosition = richEdit.Document.Range.End;
    richEdit.ScrollToCaret();
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ScrollToCaret(Single) 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.

See Also