DocumentLayout.DocumentFormatted Event
Fires after the document layout is calculated.
Namespace: DevExpress.XtraRichEdit.API.Layout
Assembly: DevExpress.RichEdit.v25.1.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.
Call the GetFormattedPageCount method in the event handler to retrieve a number of formatted pages.
Important
The Document
event handler is running in a background (non-UI) thread. Use the Rich
or Dispatcher.
(WPF) method to avoid concurrency issues. Access the Dispatcher.
method using the Rich
property.
#WinForms Example
private void DocumentLayout_DocumentFormatted(object sender, EventArgs e)
{
richEditControl1.BeginInvoke(new Action(() =>
{
int pageCount = richEditControl1.DocumentLayout.GetFormattedPageCount();
for (int i = 0; i < pageCount; i++)
{
MyDocumentLayoutVisitor visitor = new MyDocumentLayoutVisitor();
visitor.Visit(richEditControl1.DocumentLayout.GetPage(i));
}
}));
}
#WPF Example
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));
}
}));
}
#Related GitHub Examples
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.