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 customize the backcolor and forecolor of text in WinForms SyntaxEditor (EditControl)?

Platform: WinForms |
Control: EditControl

Customize the backcolor and forecolor

In Edit control, it is possible customize the Selected text Backcolor and Forecolor by using property named SelectedText and functions named RegisterBackColorFormat and SetSelectionBackColor.


RegisterBackColorFormat - To specify required color format.

SetSelectionBackColor - To customize Back color to all the selected text.

SelectedText - To find the selected text.s


Following code snippet helps to achieve this requirement.


//Find the Selected text and highlight it.
IBackgroundFormat format =
editControl1.RegisterBackColorFormat(Color.Yellow, Color.Green);
if (this.editControl1.SelectedText != null)
   for (int i = 0; i < this.editControl1.Lines.Count(); i++)
       if (this.editControl1.FindText(this.editControl1.SelectedText))



‘Find the Selected text and highlight it.
Dim format As IBackgroundFormat = editControl1.RegisterBackColorFormat(Color.Yellow, Color.Green)
If Me.editControl1.SelectedText IsNot Nothing Then
   For i As Integer = 0 To Me.editControl1.Lines.Count() - 1
       If Me.editControl1.FindText(Me.editControl1.SelectedText) Then
       End If
End If


                                                    Find and highlight the selectedtext in EditControl   

Figure 1. Find and High Light the SelectedText in Edit control with Image.


C#: Find and High Light the Selected Text C#

VB: Find and High Light the Selected Text VB

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/appearance#selection-color-customization

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