Category / Section
How to change the lexems dynamically in WinForms SyntaxEditor (EditControl)?
1 min read
Add or remove lexems
Dynamically we can change the lexems by add or remove the lexemes by using Lexem.Add or Lexem.Remove methods.
C#
//Removing Lexems from the language this.editControl1.Language.Lexems.Remove(objconfigLex); //Changing the lexems objconfigLex = new ConfigLexem(this.TextBox1.Text, "", FormatType.Custom, false); objconfigLex.IndentationGuideline = true; objconfigLex.FormatName = "HighLight"; //Add it to the current language's Lexems collection this.editControl1.Language.Lexems.Add(objconfigLex); //Reset the current configuration language cache to refelect these changes this.editControl1.Language.ResetCaches();
VB
'Removing Lexemes from the language Me.editControl1.Language.Lexems.Remove(objconfigLex) objconfigLex = New ConfigLexem(Me.TextBox1.Text, "", FormatType.Custom, False) objconfigLex.IndentationGuideline = True objconfigLex.FormatName = "HighLight" 'Add it to the current language's Lexemes collection Me.editControl1.Language.Lexems.Add(objconfigLex) 'Reset the current configuration language cache to reflect these changes Me.editControl1.Language.ResetCaches()
Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/syntax-highlighting#configure-custom-language-using-code