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.
Unfortunately, activation email could not send to your email. Please try again.

Check if lexem is underlined

Thread ID:

Created:

Updated:

Platform:

Replies:

64125 Jul 14,2007 06:07 PM Jul 17,2007 07:59 PM Windows Forms 1
loading
Tags: EditControl
Olga
Asked On July 14, 2007 06:07 PM

Hi,
I'm trying to implement the following logic:
1. user is typing something
2. i'm checking his input and underline the error, using SetUnderline.
3. when user moves cursor to the underlined text, some error info is shown ( I use UpdateContextToolTip event)
4. If user corrects error - underlining is removed

I can't find out how to determine that the lexem is underlined.

I'm using 4.4.0.51 version
thanks in advance

Sarath Kumar G [Syncfusion]
Replied On July 17, 2007 07:59 PM


Hi Olga,

Thank you for using Syncfusion products.

It is possible to extract the lexemes from the config file using "ConfigLexem - Used to parsed in an defined way". I have prepared a sample to meet to your
requirements. The sample illustrates the following criteria;

Issue 1 &2:

" User is typing something & I'm checking his input and underline the error, using SetUnderline".

The sample extracts all lexemes using "ConfigLexem" defined in "Config.xml" file and stores in an Array. In runtime when user types a word the word is
compared with the lexemes stored in the array. If the typed word is not in the lexemes list the word is underlined using "SetUnderline()" method. The following
is the code snippet to do so;


[C#]

n = editControl1.Language.Lexems.Count;
obj = new object[n];
this.editControl1.Language.Lexems.CopyTo(obj);
for (int i = 0; i < n; i++)
s[i] = ((ConfigLexem)obj[i]).BeginBlock;


Issue 3 - "when user moves cursor to the underlined text, some error info is shown ( I use UpdateContextToolTip event)"

This is achieved by triggering "UpdateContextToolTip" event. This event extracts the lexeme value and the string to display is printed out in this event. The
following is the code snippet to do so;


[C#]

this.editControl1.UpdateContextToolTip += new Syncfusion.Windows.Forms.Edit.UpdateTooltipEventHandler(this.editControl1_UpdateContextToolTip);

private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e)
{
ILexemLine line = editControl1.GetLine(pointVirtual.Y);
ILexem lexeme = line.FindLexemByColumn(pointVirtual.X);
if (lexeme != null)
{
IConfigLexem configLexem = lexem.Config as IConfigLexem;
e.Text = "This is of type " + configLexem.Format.Name + " : " + lexem.Text;
}
}


Issue 4 - "If user corrects error - underlining is removed".

This is achieved by extracting the current word from the EditControl and comparing it with the lexem's list stored in the array.

Steps to execute the program:

1) Run the attached sample.
2) Type a lexeme. (Say "null, byte, namespace....". These are the lexemes in the sample config.xml file).
3) Click the button.
4) The word will not be underlined, since the lexeme is in the config.xml file.
5) Type a lexeme not in the config.xml file. (Say "byte" - which is not in config.xml file).
6) Click the button.
7) The word will be underlined in red waved format.
8) Delete 'e' from "byte" in editcontrol.
9) Click the button.
10) The word will not be underlined, since the lexeme(byte) is in the config.xml file.
11) Move mouse pointer to 'byte' context tooltip displays.

Here is the sample program for your reference.

http://websamples.syncfusion.com/samples/Edit/F-64125/main.htm'>http://websamples.syncfusion.com/samples/Edit/F-64125/main.htm">http://websamples.syncfusion.com/samples/Edit/F-64125/main.htm

Please let me know for further help.

Regards,
Sarath

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;