[]
C1Editor provides events for drag-and-drop interactions, mouse activity, and document change notifications.
These events allow applications to monitor editor interaction, process dropped content, detect document updates, and synchronize editor state with application logic.
Typical scenarios include processing dropped files or text, tracking drag-and-drop state, responding to mouse interaction, tracking unsaved changes, and triggering validation workflows.

C1Editor supports standard drag-and-drop events for monitoring drag operations and processing dropped content.
Event | EventArgs Type | Typical Usage |
|---|---|---|
|
| Validate dragged content, initialize drag state |
|
| Update drag feedback, control drop behavior |
|
| Clear drag indicators, reset temporary state |
|
| Import dropped files or text, update document content |
Applications commonly use these events to validate dropped data, update drag feedback, and import external content into the editor.
DragEnter occurs when dragged content enters the editor surface.
c1Editor1.DragEnter += (s, e) =>
{
AddLog("DragEnter");
};DragOver
DragOver occurs while dragged content moves over the editor surface.
c1Editor1.DragOver += (s, e) =>
{
AddLog("DragOver");
};DragLeave occurs when dragged content leaves the editor surface.
c1Editor1.DragLeave += (s, e) =>
{
AddLog("DragLeave");
};DragDrop occurs when content is dropped into the editor.
c1Editor1.DragDrop += (s, e) =>
{
AddLog("DragDrop");
};C1Editor provides mouse interaction events for responding to user input within the editor surface.
Event | EventArgs Type | Typical Usage |
|---|---|---|
|
| Start interaction workflows, handle selection |
|
| Complete interactions, display context menus |
Applications commonly use these events for custom interaction workflows, selection handling, and context-menu integration.
MouseDown occurs when a mouse button is pressed inside the editor.
c1Editor1.MouseDown += (s, e) =>
{
AddLog("MouseDown");
};MouseUp occurs when a mouse button is released inside the editor.
c1Editor1.MouseUp += (s, e) =>
{
AddLog("MouseUp");
};DocumentChanged occurs when the editor content changes.
Event | EventArgs Type | Typical Usage |
|---|---|---|
|
| Track unsaved changes, trigger validation |
c1Editor1.DocumentChanged += (s, e) =>
{
AddLog("DocumentChanged");
};The event is raised for operations including typing, deleting, pasting, formatting changes, and programmatic content updates.
DocumentChanged reports that the document state changed but does not identify the specific modified content or operation. Formatting-only updates can also trigger the event.
Applications commonly use this event to:
Track unsaved changes
Enable save operations
Trigger validation workflows
Synchronize editor state with application logic
Event Processing Behavior
Event handlers execute on the UI thread.
Long-running operations inside handlers can block editor interaction and UI rendering. High-frequency events such as DocumentChanged should avoid expensive synchronous processing.
The documented events are notification events and do not provide built-in cancellation support.
The following example demonstrates how to register and handle C1Editor interaction events, including drag-and-drop, mouse, document change, and editor initialization events.
The sample also logs event activity in a RichTextBox.
public partial class Events : UserControl
{
public Events()
{
InitializeComponent();
c1Editor1.C1EditorReady += c1Editor1_C1EditorReadyAsync;
c1Editor1.ClientSizeChanged += C1Editor1_Resize;
c1Editor1.SizeChanged += C1Editor1_Resize;
c1Editor1.DragDrop += C1Editor1_DragDrop;
c1Editor1.DragEnter += C1Editor1_DragEnter;
c1Editor1.DragOver += C1Editor1_DragOver;
c1Editor1.DragLeave += C1Editor1_DragLeave;
c1Editor1.MouseUp += C1Editor1_MouseUp;
c1Editor1.MouseDown += C1Editor1_MouseDown;
c1Editor1.DocumentChanged += C1Editor1_DocumentChanged;
}
private void C1Editor1_Resize(object sender, EventArgs e)
{
c1Editor1.Focus();
}
private async void c1Editor1_C1EditorReadyAsync(object sender, EventArgs e)
{
string filename = @"Resources\tesla.html";
if (File.Exists(filename))
{
await c1Editor1.LoadDocumentAsync(Path.GetFullPath(filename));
await c1Editor1.SetDefaultStylesAsync(null, true);
}
}
private void C1Editor1_DragEnter(object? sender, DragEventArgs e)
{
AddLog("DragEnter");
}
private void C1Editor1_DragDrop(object? sender, DragEventArgs e)
{
AddLog("DragDrop");
}
private void C1Editor1_DragLeave(object? sender, EventArgs e)
{
AddLog("DragLeave");
}
private void C1Editor1_DragOver(object? sender, DragEventArgs e)
{
AddLog("DragOver");
}
private void C1Editor1_MouseDown(object? sender, MouseEventArgs e)
{
AddLog("MouseDown");
}
private void C1Editor1_MouseUp(object? sender, MouseEventArgs e)
{
AddLog("MouseUp");
}
private void C1Editor1_DocumentChanged(object? sender, EventArgs e)
{
AddLog("DocumentChanged");
}
private int count = 0;
private string lastMessage = "";
private int times = 0;
private void AddLog(string message)
{
if (message == lastMessage)
{
times++;
ReplaceLastLine(count.ToString("D3") + " - " + message + ". Times : " + times.ToString());
}
else
{
lastMessage = message;
times = 1;
count++;
AppendLine(count.ToString("D3") + " - " + message);
}
}
private void AppendLine(string text)
{
if (richTextBoxEvents.TextLength > 0)
richTextBoxEvents.AppendText("\n");
richTextBoxEvents.AppendText(text);
richTextBoxEvents.SelectionStart = richTextBoxEvents.TextLength;
richTextBoxEvents.ScrollToCaret();
}
private void ReplaceLastLine(string text)
{
int start = richTextBoxEvents.Text.LastIndexOf('\n');
start = start < 0 ? 0 : start + 1;
richTextBoxEvents.Select(start, richTextBoxEvents.TextLength - start);
richTextBoxEvents.SelectedText = text;
richTextBoxEvents.SelectionStart = richTextBoxEvents.TextLength;
}
}