We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: December 13, 2019

Content format

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

C#

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)
{
   this.editControl1.Configurator.Open(ConfigPath);
   this.editControl1.New();
   this.editControl1.LoadFile(BasePath);
}

 

VB

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
editControl1.ConfigurationChanged
    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
    Me.editControl1.Configurator.Open(ConfigPath)
    Me.editControl1.[New]()
    Me.editControl1.LoadFile(BasePath)
End Sub

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon