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

DocumentLayout.DocumentFormatted Event

Fires after the document layout is calculated.

Namespace: DevExpress.XtraRichEdit.API.Layout

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


public event EventHandler DocumentFormatted

Event Data

The DocumentFormatted event's data class is EventArgs.


Handle this event to check layout-dependent information, data and objects.

We do not recommend using this event to edit the document. Handle the RichEditControl.ContentChanged (RichEditControl.ContentChanged for WPF) or RichEditControl.DocumentLoaded (RichEditControl.DocumentLoaded for WPF) event instead.


The DocumentFormatted event handler is running in a background (non-UI) thread. Use the RichEditControl.BeginInvoke or Dispatcher.BeginInvoke (WPF) method to avoid concurrency issues. Access the Dispatcher.BeginInvoke method using the RichEditControl.Dispatcher property.

WinForms Example

Private Sub DocumentLayout_DocumentFormatted(ByVal sender As Object, ByVal e As EventArgs)

    richEditControl1.BeginInvoke(New Action(Sub()
        Dim pageCount As Integer = richEditControl1.DocumentLayout.GetFormattedPageCount()
        For i As Integer = 0 To pageCount - 1
            Dim visitor As New MyDocumentLayoutVisitor()
        Next i
    End Sub))
End Sub

WPF Example


A full code example is available in the WPF Rich Editor Layout API - Simple Example repository on GitHub.

private void DocumentLayout_DocumentFormatted(object sender, EventArgs e)

   richEdit.Dispatcher.BeginInvoke(new Action(() =>
     int pageCount = richEdit.DocumentLayout.GetFormattedPageCount();
     for (int i = 0; i < pageCount; i++)
       MyDocumentLayoutVisitor visitor = new MyDocumentLayoutVisitor();
See Also