Is there any tutorial on EditControl?

Is there any tutorial on EditControl ? The online help documentation doesn't show much information. The sample codes explorer for winforms that I downloaded has crashed as of now I can't recover it. 

I would like to accomplish the following with EditControl

1) parse text data to EditControl. Data sources are different text boxes and values from property editor
2) highlight keywords (on data load or while typing on real-time)
3) define what & where to collapse /expand
4) convert text equations (un-formated equations) into image equations

I would highly appreciate for any ideas that would help me to accomplish the above tasks 


7 Replies

MK Mallika Kannan Syncfusion Team February 6, 2018 12:47 PM UTC

Hi  Allen Zeru 
 
Thank you for contacting Syncfusion support. 
 
Please find the details in below, 
 
Query 
Response 
 parse text data to EditControl. Data sources are different text boxes and values from property editor 
Yes, you can parse the text from different text boxes to EditControl. It can be achieved using the below Code Example. 
 
Code Example: [C#] 
 
//Display the 1st TextBox text into EditControl 
private void buttonAdv1_Click(object sender, EventArgs e) 
{ 
                                    this.editControl1.Close(); 
                                    //Refresh the File content 
                                    if (File.Exists(BasePath + "\\form1.txt")) 
                                    { 
                                                File.Delete(BasePath + "\\form1.txt"); 
                                    } 
                                    //Load the file Content 
                                    for (int i = 0; i < this.textBox1.Lines.Length; i++) 
                                    { 
                                                string line = this.textBox1.Lines[i]; 
                                                StreamWriter writer = new StreamWriter(BasePath + "\\form1.txt", true); 
                                                writer.WriteLine(line); 
                                                writer.Close(); 
 
                                    } 
                                    //Read the files content 
                                    var result = File.ReadAllLines(BasePath + "\\form1.txt"); 
                                    //Write the Files Content 
                                    File.WriteAllLines(BasePath + "\\CSharp.cs", result); 
                                    //Load the cs file 
                                    this.editControl1.LoadFile(BasePath + "\\CSharp.cs"); 
} 
 
We have also prepared the sample for your reference. It can be downloaded from the below link, 
 
 
 highlight keywords (on data load or while typing on real-time) 
Editcontrol supports Syntax Highlighting and Code Coloring of some of the commonly used languages with the help of configuration files. It provides pre-defined configuration files for languages like SQL, Delphi or Pascal, HTML, VB.NET, XML, Java, VBScript, JScript and C#. 
 
We have also prepared the sample which tries to meet your requirement. In this sample, we are apply configuration using  Configurator.Open() and ApplyConfiguration() methods. Please make use of the below codes. 
 
Code Example: [C#] 
 
//Define config file path 
private string configPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\Config.xml"; 
 
public Form1() 
{ 
InitializeComponent(); 
//initial editcontrol load file 
this.editControl1.LoadFile(filePath+ "CsharpSource.cs"); 
// External configuration file. 
this.editControl1.Configurator.Open(configPath); 
// Apply the configuration defined in the configuration file. 
this.editControl1.ApplyConfiguration(Syncfusion.Windows.Forms.Edit.Enums.KnownLanguages.CSharp); 
} 
 
We have attached a sample for the same. 
 
 
define what & where to collapse /expand 
Essential Edit provides Visual Studio like support for collapsing and expanding (plus-minus buttons)  blocks of code. It can achieved using the below Code example. 
 
Code Example: [XML] 
 
<lexem ID="256" BeginBlock="{" EndBlock="}" Type="KeyWord" IsComplex="true" IsCollapsable="true" 
                                                Indent="true" CollapseName="{...}" IndentationGuideline="true" AutoFormatStartNewLine="true"> 
                                <SubLexems> 
                                                            <lexem BeginBlock="\n" IsBeginRegex="true" /> 
                                                </SubLexems> 
</lexem> 
 
 convert text equations (un-formated equations) into image equations 
We have checked your query “Unformatted Text equations into Image equation“ at our end. At present there is no default support to achieve your requirement. This feature will implemented in any of our upcoming release.  
 
 
Please get back to us with more details, if the above solution doesn’t meet your requirement. 
 
Regards, 
Mallika 
 



AL Allen February 6, 2018 04:41 PM UTC

Dear Mallika,
Thank you so much. I would highly appreciate if you can have a vs2008 compatible. I am unable to open the sample as I work on vb2008 .net 3.5
Once again, thank you


MK Mallika Kannan Syncfusion Team February 7, 2018 11:38 AM UTC

Hi Allen Zeru 
 
Thanks for your update. 
 
As per your request, we have prepared the sample for VB2008 .net 3.5 version. It can be downloaded from the below link, 
 
 
Please get back to us with more details, if the above solution doesn’t meet your requirement.  
 
Regards, 
Mallika 



AL Allen February 7, 2018 07:33 PM UTC

Dear Mallika,

Thank you so much.   After evaluating this, I just have feature related questions:

1) what would happen if there is no configuration file? I mean, is it still possible to write a code that produces effects similar to the configuration file?
2) if a configuration file is a must to have, does it mean that it has to be exported with the application (which would be visible to the end users)?
2) is there a starter example that shows how to creat a bare minimum custom keywords,, say, highlighting three keywords, one in blue, the other in red, and the third in yellow? 




MK Mallika Kannan Syncfusion Team February 8, 2018 12:05 PM UTC

Hi Allen Zeru    
   
Thanks for your update.   
   
Please find the details in below,   
 
Query 
Response 
1) what would happen if there is no configuration file? I mean, is it still possible to write a code that produces effects similar to the configuration file?   
 
EditControl has pre-defined configuration files for below languages.   
  • SQL,
  • Delphi or Pascal
  • HTML
  • C#
  • VB.NET
  • XML
  • JAVA
  • Jscript
  • VBScript
   
These configuration settings are made available in the KnownLanguages collection. So, it will produce the configuration file effect without any external configuration file.    
   
We have also provided the sample which tries to meet your requirement. In this sample, we don’t have any Configuration file.   
   
Sample:  EditControlExample 
   
Please refer this below documentation, it will guide in requested use case.   
   
  
if a configuration file is a must to have, does it mean that it has to be exported with the application (which would be visible to the end users)?   
External configuration file which is used in your application will not be visible to the end user. It is used to customize the languages in configuration setting.   
   
Please refer this below documentation will guide in requested use case.   
   
 
is there a starter example that shows how to creat a bare minimum custom keywords,, say, highlighting three keywords, one in blue, the other in red, and the third in yellow?    
 
Yes, we have prepared the sample for your query “how to create a bar minimum custom keywords,, say, highlighting three keywords, one in blue, the other in red, and the third in yellow? ”.    
In this sample we have set the Keyword named as Keyword1, Keyword2 and Keyword3 then we apply the required Font Color for this. The Following code demonstrates the Same.  
 
Code Example: [XML]   
 
<!--Assign the Keyword--> 
<lexem BeginBlock="private" Type="KeyWord1" /> 
<lexem BeginBlock="void" Type="KeyWord2" /> 
<lexem BeginBlock="char" Type="KeyWord3" /> 
 
<formats> 
<format name="Text" Font="Courier New, 10pt" FontColor="Black" /> 
<format name="Whitespace" Font="Courier New, 10pt" FontColor="Black" /> 
<!--Highlight the Keyword--> 
<format name="KeyWord1" Font="Courier New, 10pt" FontColor="Blue" /> 
<format name="KeyWord2" Font="Courier New, 10pt" FontColor="Red" /> 
<format name="KeyWord3" Font="Courier New, 10pt" FontColor="Yellow" /> 
</formats> 
 
 Screenshot 
 
 
 
 
Please check this above solution. If we have misunderstood your query please get back to us with more details like video/ Screenshot that demonstrates your requirement. This would help us to provide the solution at earliest.    
 
 
Regards   
Mallika   



AL Allen February 16, 2018 08:09 PM UTC

Thank you so much Mallika. my 2nd question was to accomplish like the example given at the following link. But I have issues with the NewConfigLanguage declaration.  What instructions should I follow to declare it?
Creating Configuration Settings Programmatically
https://help.syncfusion.com/windowsforms/syntaxeditor/configuration-settings
Dim currentConfigLanguage As IConfigLanguage = Me.editControl1.Configurator.CreateLanguageConfiguration(NewConfigLanguage)


MK Mallika Kannan Syncfusion Team February 20, 2018 05:22 PM UTC

Hi Allen T 
 
Thanks for your patience. 
 
Query: My 2nd question was to accomplish like the example given at the following link. But I have issues with the NewConfigLanguage declaration.  What instructions should I follow to declare it? 
 
To create Configuration setting programmatically, you need to parse the “New Configuration Language Name” on CreateLanguageConfiguration function. The following code demonstrates the same. 
 
Code Example: [VB] 
 
Create New Configuration Language 
Dim language As IConfigLanguage = Me.editControl1.Configurator.CreateLanguageConfiguration("New") 
'adding the required splitter 
Dim s1 As New Split("/*") 
Dim s2 As New Split("*/") 
language.Splits.Add(s1) 
language.Splits.Add(s2) 
'Apply the new Configuration language 
Me.editControl1.ApplyConfiguration(language) 
 
'Create Custom Format object named Keyword 
Dim keyword As ISnippetFormat = Me.editControl1.Language.Add("Keyword") 
'set its attributes 
keyword.Font = New Font("Arial", 10, FontStyle.Regular) 
keyword.FontColor = Color.Blue 
 
'Creating a ConfigLexem object that belongs to the above defined format. 
Dim keywordlexem1 As New ConfigLexem("private", "", FormatType.Custom, False) 
'Defining its attributes. 
keywordlexem1.FormatName = "Keyword" 
'Add the ConfigLexem object to the Lexems collection of the current language. 
Me.editControl1.Language.Lexems.Add(keywordlexem1) 
Dim keywordlexem2 As New ConfigLexem("int", "", FormatType.Custom, False) 
keywordlexem2.FormatName = "Keyword" 
Me.editControl1.Language.Lexems.Add(keywordlexem2) 
Dim configLex As New ConfigLexem("this", "", FormatType.Custom, False) 
configLex.FormatName = "Keyword" 
Me.editControl1.Language.Lexems.Add(configLex) 
 
Please refer the below documentation for further reference. 
 
 
We have prepared the sample for the same. Please download it from below location, 
 
 
Please try the above solution and let us know if it is helpful. 
 
Regards, 
Mallika 
 


Loader.
Up arrow icon