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

DocumentLayout.DocumentFormatted Event

Fires after the document layout is calculated.

Namespace: DevExpress.XtraRichEdit.API.Layout

Assembly: DevExpress.RichEdit.v20.2.Core.dll

NuGet Package: DevExpress.RichEdit.Core

Declaration

public event EventHandler DocumentFormatted

Event Data

The DocumentFormatted event's data class is EventArgs.

Remarks

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.

Important

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()
            visitor.Visit(richEditControl1.DocumentLayout.GetPage(i))
        Next i
    End Sub))
End Sub

WPF Example

Note

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();
       visitor.Visit(richEdit.DocumentLayout.GetPage(i));
     }
   }));
}

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

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