Back to Devexpress

RichEditControl.BeforeEncodingDetection Event

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

latest2.8 KB
Original Source

RichEditControl.BeforeEncodingDetection Event

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

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event EventHandler<BeforeEncodingDetectionEventArgs> BeforeEncodingDetection
vb
Public Event BeforeEncodingDetection As EventHandler(Of BeforeEncodingDetectionEventArgs)

Event Data

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

PropertyDescription
EncodingGets or sets the document encoding.
HandledGets or sets whether the event is handled.
StreamObtains 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.

csharp
using DevExpress.Office;

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

Private Sub RichEditControl_BeforeEncodingDetection(ByVal sender As Object, ByVal e As BeforeEncodingDetectionEventArgs)
  e.Encoding = Encoding.UTF8
  e.Handled = True
End Sub

See Also

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace