How can I programatically add a complex lexem to a edit control?

Hello

I'm trying to programatically add a complex lexem to a edit control, using as basis a example yours, like this:

{
string str="";
for(int i=10;i>0;i--)
{
str="[Table "+i.ToString()+ "]";
configlexem1=new ConfigLexem();
configlexem1.BeginBlock=str;
configlexem1.Type =FormatType.KeyWord;
configlexem1.IsComplex = true;

Split split1 = new Split();
split1.Text="[Table " + i.ToString() +"]";

this.editControl1.Language.Splits.Add(split1);
this.editControl1.Language.Lexems.Add(configlexem1);
this.editControl1.Language.ResetCaches();

}

this.editControl1.Refresh();
MessageBox.Show("Finished creating lexems with begin block Table1,Table2,Table3.... Table10");
this.menuItem1.Enabled=false;

}

But it does not work.
How can I programatically add a complex lexem to a edit control?
I use Visual Studio 2005 and Syncfusion 4.2.0.60

Thanks in advance



Sample2_f407d2d8.zip

2 Replies

AD Administrator Syncfusion Team February 20, 2008 12:22 AM UTC

Hi Jorge,

Thank you for your interest in Syncfusion products.

Please refer the code below to programatically add a complex lexem to a edit control,

Thank you for your interest in Syncfusion products.

ISnippetFormat keywordFormat = this.editControl1.Language.Add("Keyword");
keywordFormat.FontColor = Color.Blue;
keywordFormat.Font = new Font("Arial", 10);

// Create a lexem - this that belongs to the format - Keyword
//ConfigLexem configLex = new ConfigLexem("[A-Z]", "[A-Z]", FormatType.Custom, false);
ConfigLexem configLex = new ConfigLexem("[A-Z]+", "", FormatType.Custom, false);


configLex.IsBeginRegex = true;
configLex.IsEndRegex = true;
configLex.FormatName = "Keyword";

// Add it to the current language's lexems collection
this.editControl1.Language.Lexems.Add(configLex);
this.editControl1.Language.ResetCaches();


Please let me know if this helps.

Regards,
Srirajan




JO Jorge February 20, 2008 09:58 PM UTC

Hi Srirajan

Thank you for your quckly response. But this example does not work in my specific case. I tryed this:


ISnippetFormat keywordFormat = this.editControl1.Language.Add("Keyword");
keywordFormat.FontColor = Color.Blue;
keywordFormat.Font = new Font("Arial", 10);

// Create a lexem - this that belongs to the format - Keyword
ConfigLexem configLex = new ConfigLexem("[Test]", "", FormatType.Custom, false);


configLex.IsBeginRegex = false; // it´s not a regular ex.
configLex.IsEndRegex = false;
configLex.FormatName = "Keyword";

// Add it to the current language's lexems collection
this.editControl1.Language.Lexems.Add(configLex);
this.editControl1.Language.ResetCaches();


Note that I include brackets as literals. Unbracketed, it works perfectly
How can I use brackets as literals?

Best regards,
Jorge

>Hi Jorge,

Thank you for your interest in Syncfusion products.

Please refer the code below to programatically add a complex lexem to a edit control,

Thank you for your interest in Syncfusion products.

ISnippetFormat keywordFormat = this.editControl1.Language.Add("Keyword");
keywordFormat.FontColor = Color.Blue;
keywordFormat.Font = new Font("Arial", 10);

// Create a lexem - this that belongs to the format - Keyword
//ConfigLexem configLex = new ConfigLexem("[A-Z]", "[A-Z]", FormatType.Custom, false);
ConfigLexem configLex = new ConfigLexem("[A-Z]+", "", FormatType.Custom, false);


configLex.IsBeginRegex = true;
configLex.IsEndRegex = true;
configLex.FormatName = "Keyword";

// Add it to the current language's lexems collection
this.editControl1.Language.Lexems.Add(configLex);
this.editControl1.Language.ResetCaches();


Please let me know if this helps.

Regards,
Srirajan





Loader.
Up arrow icon