Other Useful Events

The companion page Useful Events already covers the high-volume events — HtmlChanged, Pasting, SelectionChanged, and PreProcessMessageEvent. This page documents the rest of the public event surface on WinFormHtmlEditor so you can hook editor-mode changes, file IO, context menus, element-level interaction, errors, status text, and spell-check completion.
EditorModeChanged

public event EventHandler<EventArgs> EditorModeChanged;
Fires whenever the user (or your code) switches between WysiwygDesign, HtmlEdit, and Preview modes. The event carries plain EventArgs — read the current mode from editor.EditorMode in the handler. Common uses: enable or disable host buttons that only make sense in WYSIWYG, save the user’s last mode to settings, or trigger a server-side validation pass when entering Preview.
editor.EditorModeChanged += (s, e) =>{ var mode = editor.EditorMode; btnSave.Enabled = (mode != EditorModes.Preview);};ContextMenuShowing

public event EventHandler<ContextMenuShowingEventArgs> ContextMenuShowing;
Fires just before the editor’s default context menu would open. The event args carry one property:
Point OffsetMousePosition — the cursor position relative to the editor’s client area, so you can position your own ContextMenuStrip at the click point.
If you want to fully replace the default menu, set editor.Options.ShowDefaultContextMenu = false at startup and show your own strip inside this handler.
editor.Options.ShowDefaultContextMenu = false;editor.ContextMenuShowing += (s, e) =>{ var screenPt = editor.PointToScreen(e.OffsetMousePosition); myCustomMenuStrip.Show(screenPt);};HtmlElementClicked / HtmlElementMouseDown

public event EventHandler<HtmlElementClickedEventArgs> HtmlElementClicked;
public event EventHandler<HtmlElementClickedEventArgs> HtmlElementMouseDown;
Fire when an HTML element receives a click or mouse-down inside the editor. Filter by element type at the option layer with editor.Options.FireHtmlElementClickEventFor and FireHtmlElementMouseDownEventFor (defaults to HtmlElementTypes.All; set to HtmlElementTypes.Hyperlink or Image to narrow the firing).
Event arg properties:
HtmlElement ClickedElement — the managed HtmlElement the user interacted with.
HtmlElementEventArgs EventData — the raw WinForms event args (mouse position, modifier keys, ReturnValue to cancel).
HtmlElementTypes ElementType — the resolved category (Hyperlink, Image, Table, Paragraph, Span, Div, Input, or Other).
editor.Options.FireHtmlElementClickEventFor = HtmlElementTypes.Image;editor.HtmlElementClicked += (s, e) =>{ if (e.ElementType == HtmlElementTypes.Image) { var src = e.ClickedElement.GetAttribute("src"); OpenImageInspector(src); }};FileOpened / FileSaved

public event EventHandler<FileEventArgs> FileOpened;
public event EventHandler<FileEventArgs> FileSaved;
Raised after the Content service successfully reads or writes a file (LoadBodyHtmlFromFile, LoadDocumentHtmlFromFile, OpenFile, SaveBodyHtmlToFile, SaveDocumentHtmlToFile, SaveEditorContentAsXml).
Event arg property:
string FilePath — the full path the editor just used.
editor.FileOpened += (s, e) =>{ Text = "Editor -- " + System.IO.Path.GetFileName(e.FilePath); RecentFilesList.Push(e.FilePath);};editor.FileSaved += (s, e) =>{ statusStrip.Items["status"].Text = "Saved " + e.FilePath; isDirty = false;};ErrorOccurred
public event EventHandler<ErrorEventArgs> ErrorOccurred;
Global error funnel used by internal services so the editor never silently swallows an exception. Attach this to your host’s logging pipeline.
Event arg properties (SpiceLogic.HtmlEditor.Abstractions.EditorEventArgs.ErrorEventArgs):
string Message — human-readable summary of what failed.
Exception? Exception — the underlying exception if one was caught, otherwise null.
editor.ErrorOccurred += (s, e) =>{ _logger.LogError(e.Exception, "Editor error: {Message}", e.Message);};StatusChanged
public event EventHandler<StatusChangedEventArgs> StatusChanged;
Raised when the editor wants to publish a transient status message (for example "Spell check in progress…" or "Saved"). Useful for forwarding to a host status bar so the editor never has to draw its own.
Event arg property:
string StatusMessage — the localized text to show.
The event is marshalled to the UI thread internally, so you can mutate WinForms controls directly from the handler.
editor.StatusChanged += (s, e) => statusLabel.Text = e.StatusMessage;
SpellCheckCompleted

public event EventHandler<SpellCheckCompletedEventArgs> SpellCheckCompleted;
Fires when a spell-check pass finishes — either the inline pass triggered by typing or the dialog-driven full-document pass.
Event arg property:
bool Canceled — true if the dialog user clicked Cancel; false if the pass ran to completion (including inline passes, which never set this to true).
editor.SpellCheckCompleted += (s, e) =>{ if (!e.Canceled) statusLabel.Text = "Spell check finished.";};Threading and event ordering
All of these events are raised on the WinForms UI thread (either inline from a UI message or marshalled via SynchronizationContext.Post for the file / status events). You can touch WinForms controls in the handler without Control.Invoke. Avoid long-running work inside the handler — offload to a background task and post results back via your own synchronization context.