Back to Devexpress

RichEditControl.DocumentLoaded Event

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-8a5e2f60.md

latest8.7 KB
Original Source

RichEditControl.DocumentLoaded Event

Occurs after a document is loaded into the RichEdit control.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event EventHandler DocumentLoaded
vb
Public Event DocumentLoaded As EventHandler

Event Data

The DocumentLoaded event's data class is EventArgs.

Remarks

The DocumentLoaded event fires after the RichEditControl.LoadDocument or Document.LoadDocument method call.

The event is also raised when the following properties change their values:

The DocumentLoaded fires when the document model is built and the loaded document is valid. Handle the DocumentLayout.DocumentFormatted event to check the loaded document’s layout. Please note that the DocumentLoaded event raises asynchronously.

Note

The RichEditControl does not provide a technique to determine the moment when all images with external references are downloaded and inserted in an HTML document.

The following code snippet updates fields in the main body of a loaded document:

csharp
richEditControl.LoadDocument("FirstLook.docx");
richEditControl.DocumentLoaded += RichEditControl_DocumentLoaded;

private void RichEditControl_DocumentLoaded(object sender, EventArgs e)
{
    RichEditControl control = sender as RichEditControl;
    if (control.Document.Fields.Count != 0)
    {
        control.Document.Fields.Update();
    }
}
vb
richEditControl.LoadDocument("FirstLook.docx")
AddHandler richEditControl.DocumentLoaded, AddressOf RichEditControl_DocumentLoaded

private void RichEditControl_DocumentLoaded(Object sender, EventArgs e)
    Dim control As RichEditControl = TryCast(sender, RichEditControl)
    If control.Document.Fields.Count <> 0 Then
        control.Document.Fields.Update()
    End If

The following code snippets (auto-collected from DevExpress Examples) contain references to the DocumentLoaded 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.

winforms-rich-text-editor-retain-original-image-uri-in-html-document/CS/Form1.cs#L16

csharp
InitializeComponent();
richEditControl1.DocumentLoaded += richEditControl1_DocumentLoaded;
richEditControl1.CreateNewDocument();

how-to-load-a-document-into-the-richedit-control/CS/LoadDocumentExample/Form1.cs#L15

csharp
InitializeComponent();
    richEditControl1.DocumentLoaded += RichEditControl1_DocumentLoaded;
}

how-to-specify-default-font-name-and-size/CS/DefaultDocumentSettingsExample/Form1.cs#L26

csharp
richEditControl1.EmptyDocumentCreated += RichEditControl1_EmptyDocumentCreated;
    richEditControl1.DocumentLoaded += RichEditControl1_DocumentLoaded;
}

winforms-richedit-enable-line-numbering-and-count-document-rows/CS/LineNumberingExample/Form1.cs#L22

csharp
richEditControl1.DocumentLoaded += RichEditControl1_DocumentLoaded;
richEditControl1.DocumentLayout.DocumentFormatted += DocumentLayout_DocumentFormatted;

rich-text-editor-document-content-validator/CS/ContentAnalyzer/Form1.cs#L21

csharp
richEditControl.EmptyDocumentCreated += OnEmptyDocumentCreated;
richEditControl.DocumentLoaded += OnDocumentLoaded;

winforms-rich-text-editor-retain-original-image-uri-in-html-document/VB/Form1.vb#L12

vb
InitializeComponent()
AddHandler richEditControl1.DocumentLoaded, AddressOf richEditControl1_DocumentLoaded
richEditControl1.CreateNewDocument()

how-to-load-a-document-into-the-richedit-control/VB/LoadDocumentExample/Form1.vb#L14

vb
InitializeComponent()
    AddHandler richEditControl1.DocumentLoaded, AddressOf RichEditControl1_DocumentLoaded
End Sub

how-to-specify-default-font-name-and-size/VB/DefaultDocumentSettingsExample/Form1.vb#L20

vb
AddHandler richEditControl1.EmptyDocumentCreated, AddressOf RichEditControl1_EmptyDocumentCreated
    AddHandler richEditControl1.DocumentLoaded, AddressOf RichEditControl1_DocumentLoaded
End Sub

winforms-richedit-enable-line-numbering-and-count-document-rows/VB/LineNumberingExample/Form1.vb#L18

vb
ribbonControl1.SelectedPage = exampleRibbonPage1
AddHandler richEditControl1.DocumentLoaded, AddressOf RichEditControl1_DocumentLoaded
AddHandler richEditControl1.DocumentLayout.DocumentFormatted, AddressOf Me.DocumentLayout_DocumentFormatted

rich-text-editor-document-content-validator/VB/ContentAnalyzer/Form1.vb#L23

vb
AddHandler richEditControl.EmptyDocumentCreated, AddressOf OnEmptyDocumentCreated
AddHandler richEditControl.DocumentLoaded, AddressOf OnDocumentLoaded

See Also

LoadDocument

CreateNewDocument(Boolean)

SaveDocument

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace