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

Change language syntax highliting on the fly for same file?

Hello, I have the following problem with the Editor control(latest release).

When I initialize control, I apply some language to it. For example, VB.

this.edtCodeEditor.Configurator.Open(configFile);
this.edtCodeEditor.ApplyConfiguration(KnownLanguages.VBNET);

after that, I set Text property with some code.

After that, selecting some radio button, I'd like to have the same text highlighting as C#:

this.edtCodeEditor.ApplyConfiguration(KnownLanguages.CSharp)

But C# highlighting is not applied, because the default name of my file (which does not exist really, only in the editor) is Untitled.vb.
(If I starts with CSharp configuration, I accordingly have Untitled.cs and can't apply VB.Net syntax).


What is the simplest method to change syntax highlighting without loading another file with another extension.


Regards


3 Replies

LS Lingaraj S Syncfusion Team September 14, 2010 12:05 PM UTC

Hi,

Thank you for your interest in Syncfusion products.

We are unable reproduce the mentioned issue in EditControl when change the Configuration language for Editor. We have tested the issue with simple sample and attached in following link.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=SampleTest-1437106584.zip

Please have look at the above sample and let me know if you still face the issue. Could you please try to reproduce the issue in above sample that could be helpful for us to provide a better solution?

Regards,
Lingaraj S.



AD Administrator Syncfusion Team September 14, 2010 02:49 PM UTC

yes, you're right, my example was not correct enough.
I'm attaching my sample now.

The steps are:
1. I add Editor, in Form_Load I set this.editControl1.ApplyConfiguration(KnownLanguages.VBNET);

2. I have button named C#, in OnClick method I write the following:

string custCode = "//**************************************************\r";
custCode += "// Custom C# code for " + "\r";
custCode += "// Created: " + System.DateTime.Now.ToString() + "\r";
custCode += "//**************************************************\r";

//this line is for show that in fact syntax is VB
custCode += "'this line is for show that the syntax is not shown correctly \r";
custCode += "Imports System\r";
custCode += "using System;\r";


this.editControl1.Text = custCode;
this.editControl1.ApplyConfiguration(KnownLanguages.CSharp); // won't be c#



So, I add some text and set configuration to the c#.
When I press this button, syntax highlighting won't change to C#.


I can set configuration before setting the text, in this case, C# will be shown correctly.

But in this case, if I click another button - VB.NET, where configuration is changed to the VB.NET, syntax will remain C#.





SampleTest_a3d0f97a.zip


LS Lingaraj S Syncfusion Team September 15, 2010 05:54 AM UTC

Hi,

Thanks for the update.

We usually share general informations alone on Community Forums, for issue related queries you can use our Direct Trac support at the following link,

http://www.syncfusion.com/support/directtrac

Please let us know if you have concerns on this,

Regards
Lingaraj S.


Loader.
Live Chat Icon For mobile
Up arrow icon