Articles in this section
Category / Section

How to change the font settings of the Formats in WinForms SyntaxEditor (EditControl) programmatically?

1 min read

Font settings

It is possible to change the font settings of the Formats in the EditControl programmatically using the ISnippetFormat.Font property as shown in code snippets below.

C#

private void ApplyFont()
{
   SnippetFormat format;
   Config c=this.editControl1.Configurator;
   IConfigLanguage configlang=c.GetLanguage("cs");
   ConfigLanguage configlanguage=configlang as ConfigLanguage;
   for( int i = 0, len = configlanguage.Count; i < len; i++ )
   {
      format = configlanguage[ i ] as ISnippetFormat;
      format.Font =new Font(this.newfont,fontstyle);
   }
   editControl1.ApplyConfiguration(configlanguage);
}

 

VB

Private Sub ApplyFont()
    Dim format As Syncfusion.Windows.Forms.Edit.Interfaces.ISnippetFormat
    Dim c As Syncfusion.Windows.Forms.Edit.Implementation.Config.Config =  Me.EditControl1.Configurator
    Dim configlang As Syncfusion.Windows.Forms.Edit.Interfaces.IConfigLanguage = c.GetLanguage("vb")
    Dim configlanguage As Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage = CType(IIf(TypeOf configlang Is ConfigLanguage, configlang, Nothing), ConfigLanguage)
    Dim i As Integer = 0
    Dim len As Integer = configlanguage.Count
    Do While i < len
         format = CType(IIf(TypeOf configlanguage(i) Is Syncfusion.Windows.Forms.Edit.Interfaces.ISnippetFormat, configlanguage(i), Nothing), ISnippetFormat)
         format.Font = New Drawing.Font(Me.newfont, fontstyle)
         i += 1
     Loop
     EditControl1.ApplyConfiguration(configlanguage)
     End Sub
End Class

 

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/syntax-highlighting#configure-custom-language-using-code

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied