wpf-devexpress-dot-xpf-dot-spreadsheet-dot-spreadsheetcontrol-4f99516e.md
Occurs before detecting the encoding of the loaded CSV or TXT data.
Namespace : DevExpress.Xpf.Spreadsheet
Assembly : DevExpress.Xpf.Spreadsheet.v25.2.dll
NuGet Package : DevExpress.Wpf.Spreadsheet
public event EventHandler<BeforeEncodingDetectionEventArgs> BeforeEncodingDetection
Public Event BeforeEncodingDetection As EventHandler(Of BeforeEncodingDetectionEventArgs)
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. |
The BeforeEncodingDetection event is raised when the spreadsheet attempts to detect encoding of the CSV or TXT text being imported. Handle this event to specify a custom encoding instead of the automatically detected encoding.
The event fires only if the TxtDocumentImporterOptions.AutoDetectEncoding or CsvDocumentImporterOptions.AutoDetectEncoding property is set to true.
using DevExpress.Office;
private void SpreadsheetControl_BeforeEncodingDetection(object? sender, BeforeEncodingDetectionEventArgs e)
{
e.Encoding = Encoding.UTF8;
e.Handled = true;
}
Imports DevExpress.Office
Private Sub SpreadsheetControl_BeforeEncodingDetection(ByVal sender As Object, ByVal e As BeforeEncodingDetectionEventArgs)
e.Encoding = Encoding.UTF8
e.Handled = True
End Sub
See Also