How to change the lexems dynamically in WinForms SyntaxEditor?
Add or remove lexems
Dynamically we can change the lexems by adding or removing them by using the 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
Conclusion
I hope you enjoyed learning about how to to change the lexems dynamically in WinForms SyntaxEditor.
You can refer to our WinForms Syntax Editor feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Syntax Editor example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!