Articles in this section
Category / Section

How to format the contents of the WinForms SyntaxEditor (EditControl) using the Configuration file settings?

1 min read

Content format

Please refer to the below code snippets for how to format the contents of the Edit Control using the Configuration file settings.


private string BasePath = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\Test Files\SQL.txt";
private string ConfigPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\config.xml";
this.editControl1.ConfigurationChanged += new System.EventHandler(this.editControl1_ConfigurationChanged);
private void editControl1_ConfigurationChanged(object sender, System.EventArgs e)
   foreach( FormatManager lang in editControl1.Languages )
      Format format = lang[FormatType.KeyWord] as Format;
      if( format != null )
          format.OnCustomDraw += new CustomSnippetDrawEventHandler(format_OnCustomDraw);
private void format_OnCustomDraw(object sender, CustomSnippetDrawEventArgs e)
   string text = e.Text;
   text = text.ToLower();
   text = text[0].ToString().ToUpper() + text.Substring( 1, text.Length - 1 );
   e.Text = text;
private void menuItem8_Click(object sender, System.EventArgs e)



Private BasePath As String = Path.GetDirectoryName(Application.ExecutablePath) + "\..\Test Files\SQL.txt"
Private ConfigPath As String = Path.GetDirectoryName(Application.ExecutablePath) + "\..\config.xml"
Private Sub editControl1_ConfigurationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
    Dim lang As FormatManager
    For Each lang In editControl1.Languages
        Dim format As Format = lang(FormatType.KeyWord)
        If Not (format Is Nothing) Then
           AddHandler format.OnCustomDraw, AddressOf format_OnCustomDraw
        End If
    Next lang
End Sub
Private Sub format_OnCustomDraw(ByVal sender As Object, ByVal e As CustomSnippetDrawEventArgs)
    Dim text1 As String = e.Text
    text1 = text1.ToLower()
    text1 = text1.Substring(0, 1).ToString().ToUpper() + text1.Substring(1, text1.Length - 1)
    e.Text = text1
End Sub
Private Sub menuItem8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem8.Click
End Sub


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment