The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Box

DocumentLayout.DocumentFormatted Event

Fires after the document layout is calculated.

Namespace: DevExpress.XtraRichEdit.API.Layout

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

Declaration

public event EventHandler DocumentFormatted
Public Event DocumentFormatted As EventHandler
public event EventHandler DocumentFormatted
Public Event DocumentFormatted As EventHandler

Event Data

The DocumentFormatted event handler receives an argument of the EventArgs type.

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));
     }
   }));
}
See Also