Back to Devexpress

RichEditControl.BeforeImport Event

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-d228b35f.md

latest4.0 KB
Original Source

RichEditControl.BeforeImport Event

Occurs before a document is loaded (imported from an external source).

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event BeforeImportEventHandler BeforeImport
vb
Public Event BeforeImport As BeforeImportEventHandler

Event Data

The BeforeImport event's data class is BeforeImportEventArgs. The following properties provide information specific to this event:

PropertyDescription
DocumentFormatGets the format of the document being loaded.
OptionsProvides access to the importer options.

Remarks

The BeforeImport event enables you to adjust the importer options as required.

The following example illustrates how to use the BeforeImport event to specify the location of the loaded HTML file’s external content:

csharp
private void richEditControl2_BeforeImport(object sender, BeforeImportEventArgs e) {
    if(e.DocumentFormat == DocumentFormat.PlainText) {
        ((PlainTextDocumentImporterOptions)e.Options).Encoding = cur_Encoding;
    }
}
vb
Private Sub richEditControl2_BeforeImport(ByVal sender As Object, ByVal e As BeforeImportEventArgs) Handles richEditControl2.BeforeImport
    If e.DocumentFormat = DocumentFormat.PlainText Then
        CType(e.Options, PlainTextDocumentImporterOptions).Encoding = cur_Encoding
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BeforeImport 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.

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

csharp
richEditControl.AddService(typeof(ILogUnsupportedContentService), new LogUnsupportedContentService(this.log));
richEditControl.BeforeImport += OnBeforeImport;
richEditControl.EmptyDocumentCreated += OnEmptyDocumentCreated;

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

vb
richEditControl.AddService(GetType(ILogUnsupportedContentService), New LogUnsupportedContentService(Me.log))
AddHandler richEditControl.BeforeImport, AddressOf OnBeforeImport
AddHandler richEditControl.EmptyDocumentCreated, AddressOf OnEmptyDocumentCreated

See Also

LoadDocument

DocumentLoaded

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace