Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    RichEditControl.BeforeEncodingDetection Event

    Occurs before detection of the loaded plain text or HTML encoding.

    Namespace: DevExpress.XtraRichEdit

    Assembly: DevExpress.XtraRichEdit.v25.1.dll

    NuGet Package: DevExpress.Win.RichEdit

    #Declaration

    public event EventHandler<BeforeEncodingDetectionEventArgs> BeforeEncodingDetection

    #Event Data

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

    Property Description
    Encoding Gets or sets the document encoding.
    Handled Gets or sets whether the event is handled.
    Stream Obtains a stream with document data.

    #Remarks

    The BeforeEncodingDetection event is raised when the RichEditControl attempts to detect encoding of the plain text or HTML text being imported. Handle this event to specify a custom encoding instead of the detected encoding.

    The event fires only if the PlainTextDocumentImporterOptions.AutoDetectEncoding or HtmlDocumentImporterOptions.AutoDetectEncoding property is set to true.

    using DevExpress.Office;
    
    private void RichEditControl_BeforeEncodingDetection(object? sender, BeforeEncodingDetectionEventArgs e)
    {
        e.Encoding = Encoding.UTF8;
        e.Handled = true;
    }
    
    See Also