Events in Windows Forms Syntax Editor

The EditControl is a powerful text editor control to create an interactive code editor applications with its unique feature set. It has many efficient features like editing, syntax highlighting, text indentation, intellisense, expand or collapse a block of code, custom language configuration etc. like in Microsoft Visual Studio Editor. It also provides programmatic access for most of the features like editing, intellisense, expand or collapse a block of code, and printing by raising various events.

This section discusses various events handled for the EditControl as follows.

BeforeLineNumberPaint event

This event will be triggered before the LineNumber gets painted. The LineNumber can be enabled or disabled by using the ShowLineNumbers property of the EditControl. Its default is true. To hide the LineNumber, turn on its value to false.

The event handler receives an argument of type LineNumberPaintEventArgs. The following LineNumberPaintEventArgs member provides specific information of this event.

Member Description

ForeColor

Specifies a value for the fore color of LineNumber.
// Handle before LineNumber is painted.

private void EditControl1_BeforeLineNumberPaint(object sender, Syncfusion.Windows.Forms.Edit.LineNumberPaintEventArgs e)
{
   // Sets the fore color of LineNumber in EditControl. 

    e.ForeColor = Color.Pink;
}
' Handle before LineNumber is painted.

Private Sub EditControl1_BeforeLineNumberPaint(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.LineNumberPaintEventArgs)

   'Sets the fore color of LineNumber in EditControl. 

   e.ForeColor = Color.Pink

End Sub

CanUndoRedoChanged event

This event occurs when the CanUndoRedo state is changed. The CanUndo and CanRedo properties indicates whether it is possible to undo and redo in the EditControl respectively.

The event handler receives an argument of type EventArgs.

private void editControl1_CanUndoRedoChanged(object sender, EventArgs e)

{

   Console.WriteLine(" CanUndoRedoChanged event is raised ");

}
Private Sub editControl1_CanUndoRedoChanged(ByVal sender As Object, ByVal e As EventArgs)

   Console.WriteLine(" CanUndoRedoChanged event is raised ")

End Sub

Closing event

The Closing event is triggered before a file or stream is closed in the EditControl.

private void editControl1_Closing(object sender, Syncfusion.Windows.Forms.Edit.StreamCloseEventArgs e)
{

   // Cancel the file or stream closing action.

   e.Action = SaveChangesAction.Cancel;

}
Private Sub editControl1_Closing(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.StreamCloseEventArgs) Handles EditControl1.StreamClose

   ' Cancel the file or stream closing action.

   e.Action = SaveChangesAction.Cancel

End Sub

Code Snippet events

This section discusses the following code snippet events.

CodeSnippetActivating event

This event occurs when the code snippet is to be activated.

The event handler receives an argument of type CancellableCodeSnippetsEventArgs. The following CancellableCodeSnippetsEventArgs members provide specific information of this event.

Member Description

Cancel

Indicates whether the action has to be canceled or not.

CodeSnippet

Indicates the currently activated code snippet.
private void editControl1_CodeSnippetActivating(object sender, Syncfusion.Windows.Forms.Edit.CancellableCodeSnippetsEventArgs e)

{

   // The below line will be displayed in the output window at runtime.

   Console.WriteLine(" CodeSnippetActivating event is raised ");

}
Private Sub editControl1_CodeSnippetActivating(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.CancellableCodeSnippetsEventArgs)

   ' The below line will be displayed in the output window at runtime.

   Console.WriteLine(" CodeSnippetActivating event is raised ")

End Sub

CodeSnippetDeactivating event

This event occurs when the code snippet is to be deactivated.

The event handler receives an argument of type CodeSnippetsEventArgs. The following CodeSnippetsEventArgs member provides specific information of this event.

Member Description

CodeSnippet

Code snippet that is currently activated
private void editControl1_CodeSnippetDeactivating(object sender, Syncfusion.Windows.Forms.Edit.CodeSnippetsEventArgs e)

{

   // The below line will be displayed in the output window at runtime.

   Console.WriteLine(" CodeSnippetDeactivating event is raised ");

}
Private Sub editControl1_CodeSnippetDeactivating(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.CodeSnippetsEventArgs)

   ' The below line will be displayed in the output window at runtime.

   Console.WriteLine(" CodeSnippetDeactivating event is raised ")

End Sub

CodeSnippetTemplateTextChanging event

This event is raised when the text of the code snippet template member is to be changed.

The event handler receives an argument of type CodeSnippetTemplateTextChangingEventArgs. The following CodeSnippetTemplateTextChangingEventArgs members provide specific information of this event.

Member Description

Cancel

Indicates whether the action has to be canceled or not.

CodeSnippet

Indicates currently activated code snippet.

NewText

Indicates the new text.

TemplateMemberName

Indicates the name of template member to be changed.
// Change the text of all template members with defined name of currently activated code snippet.

this.editControl1.ChangeSnippetTemplateText(" old member name", " new text");

// Handle the CodeSnippetTemplateTextChanging event.

this.editControl1.CodeSnippetTemplateTextChanging+=new Syncfusion.Windows.Forms.Edit.CodeSnippetTemplateTextChangingEventHandler(editControl1_CodeSnippetTemplateTextChanging);

private void editControl1_CodeSnippetTemplateTextChanging(object sender, Syncfusion.Windows.Forms.Edit.CodeSnippetTemplateTextChangingEventArgs e)

{

   // The below line will be displayed in the output window at runtime.

   Console.WriteLine(" CodeSnippetTemplateTextChanging event is raised ");

}
P' Change the text of all template members with defined name of currently activated code snippet.

Me.editControl1.ChangeSnippetTemplateText(" old member name", " new text")

' Handle the CodeSnippetTemplateTextChanging event.

Me.editControl1.CodeSnippetTemplateTextChanging+=New Syncfusion.Windows.Forms.Edit.CodeSnippetTemplateTextChangingEventHandler(editControl1_CodeSnippetTemplateTextChanging)

Private Sub editControl1_CodeSnippetTemplateTextChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.CodeSnippetTemplateTextChangingEventArgs)

   ' The below line will be displayed in the output window at runtime.

   Console.WriteLine(" CodeSnippetTemplateTextChanging event is raised ")

End Sub

NewSnippetMemberHighlighting event

This event is raised when a new code snippet member is highlighted.

The event handler receives an argument of type NewSnippetMemberHighlightingEventArgs. The following NewSnippetMemberHighlightingEventArgs members provide specific information of this event.

Member Description

Cancel

Indicates whether the action has to be canceled or not.

CodeSnippet

Indicates the currently activated code snippet.

NewSnippetMember

Indicates the snippet member that has to be highlighted.

OldSnippetMember

Indicates the previously highlighted snippet member.
private void editControl1_NewSnippetMemberHighlighting(object sender, Syncfusion.Windows.Forms.Edit.NewSnippetMemberHighlightingEventArgs e)

{

   // The below line will be displayed in the output window at runtime.

   Console.WriteLine(" NewSnippetMemberHighlighting event is raised ");

}
Private Sub editControl1_NewSnippetMemberHighlighting(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.NewSnippetMemberHighlightingEventArgs)

   ' The below line will be displayed in the output window at runtime.

   Console.WriteLine(" NewSnippetMemberHighlighting event is raised ")

End Sub

ConfigurationChanged event

This event is fired on changing the configuration of the EditControl. The configuration can be set by using the ApplyConfiguration function.

The event handler receives an argument of type EventArgs.

this.editControl1.ConfigurationChanged+=new EventHandler(editControl1_ConfigurationChanged);

this.editControl1.ApplyConfiguration("XML");

private void editControl1_ConfigurationChanged(object sender, EventArgs e)

{

   this.editControl1.ApplyConfiguration("XML");

}
AddHandler Me.editControl1.ConfigurationChanged, AddressOf editControl1_ConfigurationChanged 

Me.editControl1.ApplyConfiguration("XML")

Private Sub editControl1_ConfigurationChanged(ByVal sender As Object, ByVal e As EventArgs)

   Console.WriteLine(" ConfigurationChanged event is raised ")

End Sub

Collapse events

This section explains the following collapse events.

CollapsedAll event

This event is raised when the CollapseAll function is called.

The event handler receives an argument of type EventArgs.

// Handle the CollapsedAll event.

this.editControl1.CollapsedAll+=new EventHandler(editControl1_CollapsedAll);

// Call the CollapseAll function.

this.editControl1.CollapseAll();

private void editControl1_CollapsedAll(object sender, EventArgs e)

{ 

   // The below line will be displayed 

   Console.WriteLine(" CollapsedAll event is raised ");

}
' Handle the CollapsedAll event.

AddHandler Me.editControl1.CollapsedAll, AddressOf editControl1_CollapsedAll

' Call the CollapseAll function.

Me.editControl1.CollapseAll()

Private Sub editControl1_CollapsedAll(ByVal sender As Object, ByVal e As EventArgs)

   Console.WriteLine(" CollapsedAll event is raised ")

End Sub

CollapsingAll event

This event is raised when the CollapseAll function is called.

The event handler receives an argument of type CancelEventArgs. The following CancelEventArgs member provides specific information of this event.

Member Description

Cancel

Specifies a value indicating whether the event should be canceled or not.
// Handle the CollapsingAll event.

this.editControl1.CollapsingAll+=new EventHandler(editControl1_CollapsingAll);

// Call the CollapseAll function.

this.editControl1.CollapseAll();

private void editControl1_CollapsingAll(object sender, CancelEventArgs e)

{

   // The below given line will be displayed in the output window at runtime.

   Console.WriteLine(" CollapsingAll event is raised ");

   // Cancels the event.

   e.Cancel = true;

}
' Handle the CollapsingAll event.

AddHandler Me.editControl1.CollapsingAll, AddressOf editControl1_CollapsingAll

' Call the CollapseAll function.

Me.editControl1.CollapseAll()

Private Sub editControl1_CollapsingAll(ByVal sender As Object, ByVal e As CancelEventArgs)

   ' The below given line will be displayed in the output window at runtime.

   Console.WriteLine(" CollapsingAll event is raised ")

   ' Cancels the event.

   e.Cancel = True

End Sub

ContextChoice events

The EditControl provides the following set of events for performing ContextChoice operations:

* ContextChoiceBeforeOpen
* ContextChoiceSelectedTextInsert
* ContextChoiceClose
* ContextChoiceItemSelected
* ContextChoiceUpdate

ContextChoiceUpdate event

This event occurs when the context choice list is updated.

The event handler receives an argument of type IContextChoiceController. The following IContextChoiceController members provide specific information of this event.

Member Description

Dropper

Specifies the dropping lexem.

ExtendItemsFilteringString

Specifies whether the autocomplete string should be extended or not.

FormSize

Specifies size of the context choice form.

Images

Gets the collection of INamedImage items.

IsVisible

Specifies whether the context choice window associated with current controller is visible or not.

Items

Gets the collection of context choice items.

LexemBeforeDropper

Specifies the lexem situated before dropper.

SelectedItem

Specifies the currently selected item.

UseAutocomplete

Specifies whether the autocomplete technique should be used with current context choice or not.
// Create a new instance of the context choice item collection.

private ContextChoiceItemCollection c = new ContextChoiceItemCollection();

// Handle the ContextChoiceUpdate event.

this.editControl1.ContextChoiceUpdate+=new Syncfusion.Windows.Forms.Edit.ContextChoiceEventHandler(editControl1_ContextChoiceUpdate);

// IContextChoiceController.LexemBeforeDropper property returns the lexem before the dropper which displays the context choice. It is possible to control the lexem being searched in the context choice list using the ContextChoiceUpdate event.

private void editControl1_ContextChoiceUpdate(Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController controller)
{

   Console.WriteLine("LexemBeforeDropper:" + controller.LexemBeforeDropper.Text);

   controller.Items.Clear();

   foreach (IContextChoiceItem item in c)
   {
      if (item.Text.Equals(controller.LexemBeforeDropper.Text))
      {

         controller.Items.Add(item.Text);

      }
   }  

}
' Create a new instance of the context choice item collection.

Private c As ContextChoiceItemCollection = New ContextChoiceItemCollection()

' Handle the ContextChoiceUpdate event.

Me.editControl1.ContextChoiceUpdate+=New Syncfusion.Windows.Forms.Edit.ContextChoiceEventHandler(editControl1_ContextChoiceUpdate)

' IContextChoiceController.LexemBeforeDropper property returns the lexem before the dropper which displays the context choice. It is possible to control the lexem being searched in the context choice list using the ContextChoiceUpdate event.

Private Sub editControl1_ContextChoiceUpdate(ByVal controller As Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController)

   Console.WriteLine("LexemBeforeDropper:" + controller.LexemBeforeDropper.Text)

   controller.Items.Clear()

   Dim item As IContextChoiceItem

   For Each item In c

     If item.Text.Equals(controller.LexemBeforeDropper.Text) Then

       controller.Items.Add(item.Text)

     End If

   Next

End Sub

ContextChoiceOpen event

This event is discussed in the Context Choice topic.

ContextChoiceRightClick event

This event is raised when the context choice item is right-clicked.

The event handler receives an argument of type ContextChoiceItemEventArgs. The following CancelableCodeSnippetsEventArgs member provides specific information of this event.

Member Description

Item

Specifies the underlying ContextChoiceItem.
private void editControl1_ContextChoiceRightClick(Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController sender, Syncfusion.Windows.Forms.Edit.ContextChoiceItemEventArgs e)

{

   e.Item.ForeColor = System.Drawing.Color.Maroon;

   e.Item.BackColor = System.Drawing.Color.MistyRose;

   MessageBox.Show(" ContextChoiceRightClick event is raised ");

}
Private Sub editControl1_ContextChoiceRightClick(ByVal sender As Syncfusion.Windows.Forms.Edit.Interfaces.IContextChoiceController, ByVal e As Syncfusion.Windows.Forms.Edit.ContextChoiceItemEventArgs)

   e.Item.ForeColor = System.Drawing.Color.Maroon

   e.Item.BackColor = System.Drawing.Color.MistyRose

   MessageBox.Show(" ContextChoiceRightClick event is raised ")

End Sub

ContextPrompt events

The EditControl provides the following set of events for performing ContextPrompt operations:

  * ContextPromptBeforeOpen 
  * ContextPromptClose 
  * ContextPromptOpen 
  * ContextPromptSelectionChanged
  * ContextPromptUpdate

These events are discussed in the Context Prompt topic.

CursorPositionChanged event

This event is raised when the current cursor position is changed.

The event handler receives an argument of type EventArgs.

private void editControl1_CursorPositionChanged(object sender, EventArgs e)

{

   MessageBox.Show(" CurrentCursorPosition event is raised ");

}
Private Sub editControl1_CursorPositionChanged(ByVal sender As Object, ByVal e As EventArgs)

   MessageBox.Show(" CursorPositionChanged event is raised ")

End Sub

Expand events

This section discusses the expand events as follows.

ExpandedAll event

This event is raised when the ExpandAll function is called.

The event handler receives an argument of type EventArgs.

// Handle the ExpandedAll event.

this.editControl1.ExpandedAll+=new EventHandler(editControl1_ExpandedAll);

// Call the ExpandAll function.

this.editControl1.ExpandAll();

private void editControl1_ExpandedAll(object sender, EventArgs e)

{ 

   // The below line will be displayed in the output window at runtime.

   Console.WriteLine(" ExpandedAll event is raised ");

}
' Handle the ExpandedAll event.

AddHandler Me.editControl1.ExpandedAll, AddressOf editControl1_ExpandedAll

' Call the ExpandAll function.

Me.editControl1.ExpandAll()

Private Sub editControl1_ExpandedAll(ByVal sender As Object, ByVal e As EventArgs)

   ' The below line will be displayed in the output window at runtime

   Console.WriteLine(" ExpandedAll event is raised ")

End Sub

ExpandingAll event

This event is raised when the ExpandAll function is called.

The event handler receives an argument of type CancelEventArgs. The following CancelableEventArgs member provides specific information of this event.

Member Description

Cancel

Specifies a value indicating whether the event should be canceled or not.
// Handle the ExpandingAll event.

this.editControl1.ExpandingAll+=new EventHandler(editControl1_ExpandingAll);

// Call the ExpandAll function.

this.editControl1.ExpandAll();

private void editControl1_ExpandingAll(object sender, CancelEventArgs e)

{

   // The below given line will be displayed in the output window at runtime.

   Console.WriteLine(" ExpandingAll event is raised ");

   // Cancels the event.

   e.Cancel = true;

}
' Handle the ExpandingAll event.

AddHandler Me.editControl1.ExpandingAll, AddressOf editControl1_ExpandingAll

' Call the ExpandAll function.

Me.editControl1.ExpandAll()

Private Sub editControl1_ExpandingAll(ByVal sender As Object, ByVal e As CancelEventArgs)

   ' The below given line will be displayed in the output window at runtime.

   Console.WriteLine(" CollapsingAll event is raised ")

   ' Cancels the event.

   e.Cancel = True

End Sub

Find event

This event will be triggered once new match is found in FindAndReplaceDialogBox through the Find Next button.

private void EditControl1_Find(object sender, EventArgs e)
{
   // You can see the below line in output window during runtime.

   Console.WriteLine("Find event is raised")
}
Private Sub EditControl1_Find(ByVal sender As Object, ByVal e As EventArgs)

   ' You can see the below line in output window during runtime.

   Console.WriteLine("Find event is raised")   

End Sub

Indicator Margin event

This section discusses the following indicator margin events.

IndicatorMarginClick event

This event is raised when the user clicks the indicator margin area.

The event handler receives an argument of type IndicatorClickEventArgs. The following IndicatorClickEventArgs members provide specific information of this event.

Member Description

Bookmark

Gets clicked custom bookmark if available.

LineIndex

Gets clicked line index.
private void editControl1_IndicatorMarginClick(object sender, Syncfusion.Windows.Forms.Edit.IndicatorClickEventArgs e)

{

   Console.WriteLine(" IndicatorMarginClick event is raised ");

}
Private Sub editControl1_IndicatorMarginClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.IndicatorClickEventArgs)

   Console.WriteLine(" IndicatorMarginClick event is raised ")

End Sub

IndicatorMarginDoubleClick event

This event is raised when the user double-clicks the indicator margin area.

The event handler receives an argument of type IndicatorClickEventArgs. The following IndicatorClickEventArgs members provide specific information of this event.

Member Description

Bookmark

Gets clicked custom bookmark if available.

LineIndex

Gets clicked line index.
private void editControl1_IndicatorMarginDoubleClick(object sender, Syncfusion.Windows.Forms.Edit.IndicatorClickEventArgs e)

{

   Console.WriteLine(" IndicatorMarginDoubleClick event is raised ");

}
Private Sub editControl1_IndicatorMarginDoubleClick(ByVal sender As Object, ByVal e Syncfusion.Windows.Forms.Edit.IndicatorClickEventArgs)

   Console.WriteLine(" IndicatorMarginDoubleClick event is raised ")

End Sub

DrawLineMark event

This event occurs when a custom line mark should be drawn.

The event handler receives an argument of type DrawLineMarkEventArgs. The following DrawLineMarkEventArgs members provide specific information of this event.

Member Description

CustomDraw

If set to `true`, user handles drawing of the bookmark.

Graphics

Draws a graphics object.

MarkRect

Draws a rectangle where line mark should be drawn.

PhysicalLine

Draws a virtual line number.

VirtualLine

Draws a physical line number.
private void editControl1_DrawLineMark(object sender, Syncfusion.Windows.Forms.Edit.DrawLineMarkEventArgs e)

{

   if( e.VirtualLine % 2 == 0 )

   {

     Brush brush = new LinearGradientBrush(e.MarkRect, Color.Red, Color.Yellow, LinearGradientMode.Vertical);

     e.Graphics.FillRectangle(brush, e.MarkRect);

     e.Graphics.DrawRectangle(Pens.IndianRed, e.MarkRect);

   } 

}
Private Sub editControl1_DrawLineMark(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.DrawLineMarkEventArgs)

   If e.VirtualLine Mod 2 = 0 Then

     Dim brush As Brush = New Drawing2D.LinearGradientBrush(e.MarkRect, Color.Red, Color.Yellow, LinearGradientMode.Vertical)

     e.Graphics.FillRectangle(brush, e.MarkRect)

     e.Graphics.DrawRectangle(Pens.IndianRed, e.MarkRect)

   End If

End Sub

InsertModeChanged event

This event is fired when the value of the InsertMode property changes. The InsertMode property specifies the insert mode state.

The event handler receives an argument of type EventArgs.

// Handle the InsertModeChanged event.

this.editControl1.InsertModeChanged+=new EventHandler(editControl1_InsertModeChanged);

// Set the value of the InsertMode property.

this.editControl1.InsertMode = false;

private void editControl1_InsertModeChanged(object sender, EventArgs e)

{

   // The below statement can be seen in the output window at runtime.

   Console.WriteLine(" InsertModeChanged event is raised ");

}
' Handle the InsertModeChanged event.

AddHandler Me.editControl1.InsertModeChanged, AddressOf editControl1_InsertModeChanged 

' Set the value of the InsertMode property.

Me.editControl1.InsertMode = False

Private Sub editControl1_InsertModeChanged(ByVal sender As Object, ByVal e As EventArgs)

   'The below statement can be seen in the output window at runtime.

   Console.WriteLine(" InsertModeChanged event is raised ")

End Sub

LanguageChanged event

This event occurs when the current parser language is changed.

The event handler receives an argument of type EventArgs.

private void editControl1_LanguageChanged(object sender, EventArgs e)

{

   Console.WriteLine(" LanguageChanged event is raised ");

}
Private Sub editControl1_LanguageChanged(ByVal sender As Object, ByVal e As EventArgs)

   Console.WriteLine(" LanguageChanged event is raised ")

End Sub

This event is discussed in the Customizable Context Menu topic.

Operation events

This section discusses the following operation events.

OperationStarted event

This event occurs when an operation starts while collapsing and expanding the block of code.

The event handler receives an argument of type ILongOperation. The following ILongOperation members provide specific information of this event.

Member Description

ID

Specifies the ID of the operation.

IsRunning

Specifies a value indicating whether the operation is running now or not.

Name

Specifies the name of the operation.

RunningTime

Specifies the time of the operation activity.
private void editControl1_OperationStarted(Syncfusion.Windows.Forms.Edit.Interfaces.ILongOperation operation)

{

   Console.WriteLine(" OperationStarted event is raised ");

}
Private Sub editControl1_OperationStarted(ByVal operation As Syncfusion.Windows.Forms.Edit.Interfaces.ILongOperation)

   Console.WriteLine(" OperationStarted event is raised ")

End Sub

OperationStopped event

This event occurs when an operation ends.

The event handler receives an argument of type ILongOperation. The following ILongOperation members provide specific information of this event.

Member Description

ID

Specifies the ID of the operation.

IsRunning

Specifies a value indicating whether the operation is running now or not.

Name

Specifies the name of the operation.

RunningTime

Specifies the time of the operation activity.
private void editControl1_OperationStopped(Syncfusion.Windows.Forms.Edit.Interfaces.ILongOperation operation)

{

   Console.WriteLine(" OperationStopped event is raised ");

}
Private Sub editControl1_OperationStopped(ByVal operation As Syncfusion.Windows.Forms.Edit.Interfaces.ILongOperation)

   Console.WriteLine(" OperationStopped event is raised ")

End Sub

Outlining event

This section discusses the following outlining events.

OutliningBeforeCollapse event

This event is raised before a region is about to collapse.

The event handler receives an argument of type OutliningEventArgs. The following OutliningEventArgs members provide specific information of this event.

Member Description

Cancel

Specifies a value indicating whether the user cancels the underlying event or not.

CollapsedText

Specifies the CollapsedText.

CollapseName

Specifies the CollapseName.

Collapser

Specifies the Collapser.
private void editControl1_OutliningBeforeCollapse(object sender, Syncfusion.Windows.Forms.Edit.OutliningEventArgs e)

{

   Console.WriteLine(" OutliningBeforeCollapse event is raised ");

}
Private Sub editControl1_OutliningBeforeCollapse(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.OutliningEventArgs)

   Console.WriteLine(" OutliningBeforeCollapse event is raised ")

End Sub

OutliningBeforeExpand event

This event is raised before a region is about to expand.

The event handler receives an argument of type OutliningEventArgs. The following OutliningEventArgs members provide specific information of this event.

Member Description

Cancel

Specifies a value indicating whether the user cancels the underlying event or not.

CollapsedText

Specifies the CollapsedText.

CollapseName

Specifies the CollapseName.

Collapser

Specifies the Collapser.
private void editControl1_OutliningBeforeExpand(object sender, Syncfusion.Windows.Forms.Edit.OutliningEventArgs e)

{

   Console.WriteLine(" OutliningBeforeExpand event is raised ");

}
Private Sub editControl1_OutliningBeforeExpand(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.OutliningEventArgs)

   Console.WriteLine(" OutliningBeforeExpand event is raised ")

End Sub

OutliningCollapse event

This event is raised when a region collapses.

The event handler receives an argument of type CollapseEventArgs. The following CollapseEventArgs members provide specific information of this event.

Member Description

CollapsedText

Specifies the CollapsedText.

CollapseName

Specifies the CollapseName.

Collapser

Specifies the Collapser.
private void editControl1_OutliningCollapse(object sender, Syncfusion.Windows.Forms.Edit.CollapseEventArgs e)

{

   Console.WriteLine(" OutliningCollapse event is raised ");

}
Private Sub editControl1_OutliningCollapse(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.CollapseEventArgs)

   Console.WriteLine(" OutliningBeforeCollapse event is raised ")

End Sub

OutliningExpand event

This event is raised when a region expands.

The event handler receives an argument of type CollapseEventArgs. The following CollapseEventArgs members provide specific information of this event.

Member Description

CollapsedText

Specifies the CollapsedText.

CollapseName

Specifies the CollapseName.

Collapser

Specifies the Collapser.
private void editControl1_OutliningExpand(object sender, Syncfusion.Windows.Forms.Edit.CollapseEventArgs e)

{

   Console.WriteLine(" OutliningExpand event is raised ");

}
Private Sub editControl1_OutliningExpand(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.CollapseEventArgs)

   Console.WriteLine(" OutliningExpand event is raised ")

End Sub

OutliningTooltipBeforePopup event

This event is discussed in the Outlining ToolTip topic.

OutliningTooltipClose event

This event is raised when the outlining tooltip is closed.

The event handler receives an argument of type CollapseEventArgs. The following CollapseEventArgs members provide a specific information of this event.

Member Description

CollapsedText

Specifies the CollapsedText.

CollapseName

Specifies the CollapseName.

Collapser

Specifies the Collapser.
private void editControl1_OutliningTooltipClose(object sender, Syncfusion.Windows.Forms.Edit.CollapseEventArgs e)

{

   Console.WriteLine(" OutliningTooltipClose event is raised ");

}
Private Sub editControl1_OutliningTooltipClose(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.CollapseEventArgs)

   Console.WriteLine(" OutliningTooltipClose event is raised ")

End Sub

OutliningTooltipPopup event

This event is raised when the outlining tooltip is shown.

The event handler receives an argument of type CollapseEventArgs. The following CollapseEventArgs members provide specific information of this event.

Member Description

CollapsedText

Specifies the CollapsedText.

CollapseName

Specifies the CollapseName.

Collapser

Specifies the Collapser.
private void editControl1_OutliningTooltipPopup(object sender, Syncfusion.Windows.Forms.Edit.CollapseEventArgs e)

{

   Console.WriteLine(" OutliningTooltipPopup event is raised ");

}
Private Sub editControl1_OutliningTooltipPopup(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.CollapseEventArgs)

   Console.WriteLine(" OutliningTooltipPopup event is raised ")

End Sub

It has the following events.

PrintHeader event

This event is discussed in the Printing topic.

PrintFooter event

This event is discussed in the Printing topic.

ReadOnlyChanged event

This event occurs when the ReadOnly property is changed. The ReadOnly property specifies whether the EditControl is in the read-only mode or not.

The event handler receives an argument of type EventArgs.

// Handle the ReadOnlyChanged event.

this.editControl1.ReadOnlyChanged+=new EventHandler(editControl1_ReadOnlyChanged);

// Set the ReadOnly property to True.

this.editControl1.ReadOnly = true;

private void editControl1_ReadOnlyChanged(object sender, EventArgs e)

{

   Console.WriteLine(" ReadOnlyChanged event is raised ");

}
' Handle the ReadOnlyChanged event.

AddHandler Me.editControl1.ReadOnlyChanged, AddressOf editControl1_ReadOnlyChanged

' Set the ReadOnly property to True.

Me.editControl1.ReadOnly = True

Private Sub editControl1_ReadOnlyChanged(ByVal sender As Object, ByVal e As EventArgs)

   Console.WriteLine(" ReadOnlyChanged event is raised ")

End Sub

RegisteringDefaultKeyBindings event

This event is discussed in the Keystroke - Action Combinations Binding topic.

RegisteringKeyCommands event

This event is discussed in the Keystroke - Action Combinations Binding topic.

Save events

This section discusses the following events that are generated when the user saves the files and streams with data loss.

SaveFileWithDataLoss event

This event is raised when user tries to save the files with data loss.

The event handler receives an argument of type SaveWithDataLosingEventArgs. The following SaveWithDataLosingEventArgs members provide specific information of this event.

Member Description

SaveWithLoss

Specifies a value that indicates whether data has to be saved with loss or not.

UserHandling

Specifies a value that indicates whether the user handled this event or not.
private void editControl1_SaveFileWithDataLoss(object sender, Syncfusion.Windows.Forms.Edit.SaveWithDataLosingEventArgs e)

{

   e.SaveWithLoss = true;

   e.UserHandling = true;

}
Private Sub editControl1_SaveFileWithDataLoss(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.SaveWithDataLosingEventArgs)

   e.SaveWithLoss = True

   e.UserHandling = True

End Sub

SaveStreamWithDataLoss event

This event is raised when the user tries to save the streams with data loss.

The event handler receives an argument of type SaveWithDataLosingEventArgs. The following SaveWithDataLosingEventArgs members provide specific information of this event.

Member Description

SaveWithLoss

Specifies a value that indicates whether the data has to be saved with loss or not.

UserHandling

Specifies a value that indicates whether the user handled this event or not.
private void editControl1_SaveStreamWithDataLoss(object sender, Syncfusion.Windows.Forms.Edit.SaveWithDataLosingEventArgs e)

{

   e.SaveWithLoss = true;

   e.UserHandling = true;

}
Private Sub editControl1_SaveStreamWithDataLoss(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.SaveWithDataLosingEventArgs)

   e.SaveWithLoss = True

   e.UserHandling = True

End Sub

Scroll events

This section discusses the following events that are generated when horizontal and vertical scrolling takes place.

HorizontalScroll event

This event is raised when user scrolls the window horizontally.

The event handler receives an argument of type ScrollEventArgs. The following ScrollEventArgs members provide specific information of this event.

Member Description

NewValue

Specifies the new System.Windows.Forms.ScrollBar.Value for the scrollbar.

OldValue

Specifies the old System.Windows.Forms.ScrollBar.Value for the scrollbar.

ScrollOrientation

Gets the scrollbar orientation that raised the scroll event.

Type

Gets the type of scroll event that occurred.
private void editControl1_HorizontalScroll(object sender, ScrollEventArgs e)

{

   Console.WriteLine(" HorizontalScroll event is raised ");

}
Private Sub editControl1_HorizontalScroll(ByVal sender As Object, ByVal e As ScrollEventArgs)

   Console.WriteLine(" HorizontalScroll event is raised ")

End Sub

VerticalScroll event

This event is raised when the user scrolls the window vertically.

The event handler receives an argument of type ScrollEventArgs. The following ScrollEventArgs members provide specific information of this event.

Member Description

NewValue

Specifies the new System.Windows.Forms.ScrollBar.Value for the scrollbar.

OldValue

Specifies the old System.Windows.Forms.ScrollBar.Value for the scrollbar.

ScrollOrientation

Gets the scrollbar orientation that raised the scroll event.

Type

Gets the type of scroll event that occurred.
private void editControl1_VerticalScroll(object sender, ScrollEventArgs e)

{

   Console.WriteLine(" VerticalScroll event is raised ");

}
Private Sub editControl1_VerticalScroll(ByVal sender As Object, ByVal e As ScrollEventArgs)

   Console.WriteLine(" VerticalScroll event is raised ")

End Sub

SelectionChanged event

This event is raised when the text selection has been changed.

The event handler receives an argument of type EventArgs.

private void editControl1_SelectionChanged(object sender, EventArgs e)

{

   MessageBox.Show(" SelectionChanged event is raised ");

}
Private Sub editControl1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)

   MessageBox.Show(" SelectionChanged event is raised ")

End Sub

SingleLineChanged event

This event is fired when the value of the SingleLineMode property is changed. The SingleLineMode property specifies whether the single line mode is enabled or not.

The event handler receives an argument of type EventArgs.

// Handle the SingleLineChanged event.

this.editControl1.SingleLineChanged+=new EventHandler(editControl1_SingleLineChanged);

// Set the SingleLineMode property to True.

this.editControl1.SingleLineMode = true;

private void editControl1_SingleLineChanged(object sender, EventArgs e)

{

   // The below statement can be seen in the output window at runtime.

   Console.WriteLine(" SingleLineChanged event is raised ");

}
' Handle the SingleLineChanged event. 

AddHandler Me.editControl1.SingleLineChanged, AddressOf editControl1_SingleLineChanged 

' Set the SingleLineMode property to True. 

Me.editControl1.SingleLineMode = True 

Private Sub editControl1_SingleLineChanged(ByVal sender As Object, ByVal e As EventArgs)

   ' The below statement can be seen in the output window at runtime.

   Console.WriteLine(" SingleLineChanged event is raised ")

End Sub

Text events

This section discusses the following text events:

  • TextChanged
  • TextChanging

TextChanged event

This event is fired when the text in the EditControl is changed.

The event handler receives an argument of type EventArgs.

// Handle the TextChanged event.

this.editControl1.TextChanged += new EventHandler(editControl1_TextChanged);

// Set the text of the EditControl.

this.editControl1.Text = "Sample Text";

private void editControl1_TextChanged(object sender, EventArgs e)

{

   // The below statement can be seen in the output window at runtime.

   Console.WriteLine(" TextChanged event is raised ");

}
' Handle the TextChanged event.

AddHandler Me.editControl1.TextChanged, AddressOf editControl1_TextChanged 

' Set the text of the EditControl.

Me.editControl1.Text = "Sample Text"

Private Sub editControl1_TextChanged(ByVal sender As Object, ByVal e As EventArgs)

   ' The below statement can be seen in the output window at runtime.

   Console.WriteLine(" TextChanged event is raised ")

End Sub

TextChanging event

This event is raised when the text is to be changed.

The event handler receives an argument of type TextChangingEventArgs. The following TextChangingEventArgs members provide specific information of this event.

Member Description

Cancel

Specifies the value indicating whether the text change has been canceled.

StartColumn

Specifies the virtual start column of Insert or Delete.

StartLine

Specifies the virtual start line of Insert or Delete.

Text

Specifies the text of the event.

Type

Specifies type of the event (Changed, Insert, or Delete).
private void editControl1_TextChanging(object sender, Syncfusion.Windows.Forms.Edit.TextChangingEventArgs e)

{

   e.Type = Syncfusion.Windows.Forms.Edit.Enums.TextChange.Deleted;

   // The below statement can be seen in the output window at runtime when the text of the EditControl is deleted.

   Console.WriteLine(" TextChanging event is raised ");

}
Private Sub editControl1_TextChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.TextChangingEventArgs)

   e.Type = Syncfusion.Windows.Forms.Edit.Enums.TextChange.Deleted

   ' The below statement can be seen in the output window at runtime when the text of the EditControl is deleted. 

   Console.WriteLine(" TextChanging event is raised ")

End Sub

Line Modification events

The line modification events occur whenever a line in the EditControl is subjected to a change by modifying the text of an existing line, inserting a line, or removing a line in the editor.

The following events are triggered from the control when the editor is modified.

Line Changed

The LineChanged event will be fired when any line is modified in the EditControl.

// Handle the LineChanged event.

this.editControl1.LineChanged  += new Syncfusion.Windows.Forms.Edit.TextChangingEventHandler(editControl1_LineChanged);

Private void editControl1_LineChanged(object sender,Syncfusion.Windows.Forms.Edit.TextChangingEventArgs e)

{ 

   //The following statement can be seen in the output window at run time.

   Console.WriteLine("Line Changed");

 }
Handle the LineChanged event.

AddHandler Me.editControl1.LineChanged, AddressOf Me.editControl1_LineChanged

Private Sub editControl1_LineChanged(ByVal , As object sender, ByVal e As Syncfusion.Windows.Forms.Edit.TextChangingEventArgs)

   The following statement can be seen in the output window at runtime.

   Console.WriteLine("Line Changed")

End Sub

Line Inserted

The LineInserted event will be fired when a new line is inserted in the EditControl.

// Handle the LineInserted event.

this.editControl1.LineInserted += new Syncfusion.Windows.Forms.Edit.LineInsertedEventHandler(editControl1_LineInserted);

private void editControl1_LineInserted(object sender,Syncfusion.Windows.Forms.Edit.LinesEventArgs e)

{

   // The following statement can be seen in the output window at run time.

   Console.WriteLine("Line Inserted");

}
Handle the LineInserted event.
   
AddHandler Me.editControl1.LineInserted, AddressOf Me.editControl1_LineInserted

Private Sub editControl1_LineInserted(ByVal , As object sender, ByVal e As Syncfusion.Windows.Forms.Edit.LinesEventArgs)

   The following statement can be seen in the output window at run time.
   
   Console.WriteLine("Line Inserted")

End Sub

Line Deleted

The LineDeleted event will be fired when any line is removed from the EditControl.

// Handle the LineDeleted event.

this.editControl1.LineDeleted += new Syncfusion.Windows.Forms.Edit.LineDeletedEventHandler(editControl1_LineDeleted);

Private void editControl1_LineDeleted(object sender, Syncfusion.Windows.Forms.Edit.LinesEventArgs e)

{

   // The following statement can be seen in the output window at run time.

   Console.WriteLine("Line Deleted");

}
Handle the LineDeleted event.   

AddHandler Me.editControl1.LineDeleted, AddressOf Me.editControl1_LineDeleted

Private Sub editControl1_LineDeleted(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.LinesEventArgs)

   The following statement can be seen in the output window at run time.
    
   Console.WriteLine("Line Deleted")

End Sub

UnreachableTextFound event

This event occurs when the text in a hidden block is found. This block cannot be expanded if you cancel it.

The event handler receives an argument of type UnreachableTextFoundEventArgs. The following UnreachableTextFoundEventArgs members provide specific information of this event.

Member Description

ContinueSearch

Indicates whether search must be continued

Point

Point of the location of unreachable text

Text

Searched text
private void editControl1_UnreachableTextFound(object sender, Syncfusion.Windows.Forms.Edit.UnreachableTextFoundEventArgs e)

{

   Console.WriteLine(" UnreachableTextFound event is raised ");

}
Private Sub editControl1_UnreachableTextFound(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.UnreachableTextFoundEventArgs)

   Console.WriteLine(" UnreachableTextFound event is raised ")

End Sub

UpdateBookmarkToolTip event

This event is fired when the bookmark tooltip text is updated.

The event handler receives an argument of type UpdateBookmarkTooltipEventArgs. The following UpdateBookmarkTooltipEventArgs members provide specific information of this event.

Member Description

Bookmark

Specifies bookmark.

HintedArea

Specifies a rectangle that represents an object which has this tooltip.

Image

Specifies an image associated with the tooltip.

Line

Specifies an index of the bookmarked line.

Text

Specifies text of the tooltip.

X

Specifies Mouse X coordinate in client coordinates.

Y

Specifies Mouse Y coordinate in client coordinates.
// Handle the UpdateBookmarkToolTip event.

this.editControl1.UpdateBookmarkToolTip+=new Syncfusion.Windows.Forms.Edit.UpdateBookmarkTooltipEventHandler(editControl1_UpdateBookmarkToolTip);

// Set the bookmark at the specified line.

this.editControl1.BookmarkAdd(this.editControl1.CurrentLine);

// Specify whether bookmark tooltip should be shown.

this.editControl1.ShowBookmarkTooltip = true;

private void editControl1_UpdateBookmarkToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateBookmarkTooltipEventArgs e)

{ 

   // Set the bookmark tooltip text.

   e.Text = " Introduction to Essential Edit ";

}
' Handle the UpdateBookmarkToolTip event. 

AddHandler Me.editControl1.UpdateBookmarkToolTip, AddressOf editControl1_UpdateBookmarkToolTip 

' Set the bookmark at the specified line. 

Me.editControl1.BookmarkAdd(Me.editControl1.CurrentLine) 

' Specify whether bookmark tooltip should be shown. 

Me.editControl1.ShowBookmarkTooltip = True

Private Sub editControl1_UpdateBookmarkToolTip(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Edit.UpdateBookmarkTooltipEventArgs)

   ' Set the bookmark tooltip text. 

   e.Text = " Introduction to Essential Edit "

End Sub

UpdateContextToolTip event

This event is discussed in the Context Tooltip topic.

User Margin events

This section discusses the following user margin events.

DrawUserMarginText event

This event is discussed in the User Margin topic.

PaintUserMargin event

This event occurs when the user margin has to be painted. The user margin in EditControl can be enabled or disabled by using the ShowUserMargin property. Its default value is false. To show the user margin, turn on its value to true.

The event handler receives an argument of type PaintEventArgs. The following PaintEventArgs members provide specific information of this event.

Member Description

ClipRectangle

Gets the rectangle area to paint.

Graphics

Gets the graphics used to paint.
private void editControl1_PaintUserMargin(object sender, PaintEventArgs e)
{

   Console.WriteLine(" PaintUserMargin event is raised ");

}
Private Sub editControl1_PaintUserMargin(ByVal sender As Object, ByVal e As PaintEventArgs)

   Console.WriteLine(" PaintUserMargin event is raised ")

End Sub

WordWrapChanged event

This event is fired when the value of the WordWrapMode property is changed. The WordWrapMode property specifies the mode of word wrapping.

The event handler receives an argument of type EventArgs.

// Handle the WordWrapChanged event.

this.editControl1.WordWrapChanged+=new EventHandler(editControl1_WordWrapChanged);

// Specify the mode of word wrapping.

this.editControl1.WordWrapMode = Syncfusion.Windows.Forms.Edit.Enums.WordWrapMode.WordWrapMargin;

private void editControl1_WordWrapChanged(object sender, EventArgs e)

{  

   // The below line will be displayed in the output window at runtime.

   Console.WriteLine(" WordWrapChanged event is raised ");

}
' Handle the WordWrapChanged event. 

AddHandler Me.editControl1.WordWrapChanged, AddressOf editControl1_WordWrapChanged 

' Specify the mode of word wrapping. 

Me.editControl1.WordWrapMode = Syncfusion.Windows.Forms.Edit.Enums.WordWrapMode.WordWrapMargin 

Private Sub editControl1_WordWrapChanged(ByVal sender As Object, ByVal e As EventArgs)

   ' The below line will be displayed in the output window at runtime.

   Console.WriteLine(" WordWrapChanged event is raised ")

End Sub