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

Highlighting 2 Different Colors on 1 Lexem


I am trying to highlight two different colors on one Lexem.
This is for music chords.... I want the [" and "]" to be one color and the actual chord all red.

My formats are okay... won't show them here

Example output....


See code...

<lexem BeginBlock="[" EndBlock="]" Type="Operator" IsComplex="true">
<lexem BeginBlock="[1-9a-gA-G]" EndBlock="[1-9a-gA-G]" IsEndRegex="true" Type="Custom" FormatName="Chord" />

Do I have to parse them separately or can I do them using Sublexems like above?

Thanks in Addvance

4 Replies

VI Vinothini Syncfusion Team June 2, 2016 07:29 AM UTC

Hi Frank,


Thank you for contacting Syncfusion support.


This requirement for highlighting two different colors can be achieved by using sublexems as per your code. In addition we need to configure the lexem in the Sublexem region using Split, which contain list of expressions that must be treated as a single word. Since the sublexem includes the regular expression content we need to include the following code snippet in the configuration file.


Code Snippet [XML] : 



   <split IsRegex="true">[A-Ga-g0-9]</split>

   <split IsRegex="true">[0-9A-Ga-g]</split>




We have prepared a sample for your reference which can be downloaded from the following location.


Sample Location : http://www.syncfusion.com/downloads/support/directtrac/general/EDITCO~1-628836919.ZIP


Please let us know whether this solution satisfies your requirement.




RP Ranjani Prabhakaran Syncfusion Team July 12, 2016 05:33 AM UTC

That code works…. THANK YOU! 
Next Q: (I looked all  through the docs, couldn’t find the answer). 
How do I redraw the colored text once I edit the contents of the edit box? 
I tried refresh() and it doesn’t seem to work. 
“[Gmaj]” then becomes “[Gbmaj7]” when I edit the text during runtime. 
The “b” & “7” stay black while the other text stays colored 
Frank Hilton  

FH Frank Hilton July 12, 2016 11:56 AM UTC

I figured it out. I had to update the Config.XML

However, the application I am building...
I need to know how to update (re-paint) the text in the editor.
I am going to be building a "Transpose" function that changes all the chords in the editor.

So, can you explain to me what actually happens when I have to replace text.
Does the editor automatically redraw?
How does it "refresh"?


VR Venkateshwaran Ramdoss Syncfusion Team July 13, 2016 09:02 AM UTC

Hi Frank, 

Thank you for your update. 

Query 1: Need to know how to rendering functionality works in EditControl  
In EditControl, Text Input will be rendered always and Syntax coloring will be applied based on the definitions provided in EditControl.  

Query 2: Implementing function to update the Chords 
We are unable to understand this. Could you please let us know what is updated in EditControl, with an example? 

Query 3: Will Text will be rendered automatically when it is replaced in EditControl? 
Yes, EditControl will be re-rendered based on its Text Input update.  

Otherwise, would it be possible for you to share us the sample for this? That will be helpful for us to analyze and provide prompt solution at the earliest.  

Venkateshwaran V.R. 

Live Chat Icon For mobile
Up arrow icon