How to configure text in WinForms SyntaxEditor through configurationa dialog window?
Show configuration dialog
In WinForms EditControl, at runtime Syntax highlighting functionality can be customized by using class named “ConfigurationDialog” and Interface named “IConfig”.
Following code examples demonstrates the same.
C#
IConfigLanguage activeLang = this.editControl1.Parser.Formats as IConfigLanguage; ConfigurationDialog editConfig = new ConfigurationDialog(this.editControl1.Configurator, activeLang); //Display the EditControl configuration dialog if (editConfig.ShowDialog(this) == DialogResult.OK && activeLang != null) { IConfigLanguage newLang = editConfig.Configurator.KnownLanguageNames.Contains(activeLang.Language)? editConfig.Configurator[activeLang.Language]: editConfig.Configurator.DefaultLanguage; if (newLang != null) { this.editControl1.Configurator = editConfig.Configurator; this.editControl1.ApplyConfiguration(newLang); } }
VB
Dim activeLang As IConfigLanguage = TryCast(Me.editControl1.Parser.Formats, IConfigLanguage) Dim editConfig As New ConfigurationDialog(Me.editControl1.Configurator, activeLang) 'Display the EditControl configuration dialog If editConfig.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK AndAlso activeLang IsNot Nothing Then Dim newLang As IConfigLanguage = If (editConfig.Configurator.KnownLanguageNames.Contains(activeLang.Language), editConfig.Configurator(activeLang.Language), editConfig.Configurator.DefaultLanguage) If newLang IsNot Nothing Then Me.editControl1.Configurator = editConfig.Configurator Me.editControl1.ApplyConfiguration(newLang) End If End If
Figure 1. Customize Syntax highlighting in Edit control runtime with image.
Sample Links:
C#: How to customize Syntax highlighting in Edit control runtime C#
VB: How to customize Syntax highlighting in Edit control runtime VB
Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/syntax-highlighting
Conclusion
I hope you enjoyed learning about how to configure text in WinForms SyntaxEditor (EditControl) through configurationa dialog window.
You can refer to our WinForms EditControl feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation 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!