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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to highlight the text while it end with some specific character?

Platform: WinForms |
Control: EditControl |
.NET Framework: 4

We can customize the color of line if it is end with specific character. It can be achieved by setting the lexem in custom config file.



It contains rules for parsing the text. There are two attributes to specify the format of the lexem.


  1. Type: Type is used for standard predefined types of the lexems.
  2. FormatName: The FormatName is used only when Type is Custom.


Here we have highlighted the line if end with “!” character. The following code demonstrates the same.



<!-- Configuaration -->


<ConfigLanguage name="new" CaseInsensitive="true">




<!-- Highlight color -->


<format name="String" Font="Courier New, 13pt, style=Bold" FontColor="Green" />












<!-- Set the Required Highlight format -->


<lexem BeginBlock="[A-z\s]+\!" IsBeginRegex="true"  Type="String"/>






<split IsRegex="true">[A-z\s]+\!</split>








//Define config file path
private string configPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\..\\..\\Config.xml";
public Form1()
editControl1.Text = "Hello World!" + Environment.NewLine + "Welcome" + Environment.NewLine + "Have a Good Day!";
// External configuration file.
// Apply the configuration defined in the configuration file.




Showing different format of text in EditControl


Sample: SyntaxEditorSample


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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