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

Previously recognised keyword

Hello,

I am currently evaluating your .net controls for use in our products.

I am having difficulty finding out how to get the last identified keyword in the Edit control from the current cursor position.

For example, if a user enters the following SQL code into the editor control.

Select Field1, Field2, Field3 from MyTable

And then positions the cursor within the MyTable text, i would expect a function to return the FROM keyword or if the user placed the cursor in the Field2 text, i would expect this to return SELECT.

Could you point me to the correct way of doing this.

Unfortunately i am unable to download any attatchments in work, so if you could post the code here this would be very much appreciated.

Thanks
Scott

3 Replies

KN Karikalan Natarajan Syncfusion Team May 12, 2010 10:38 AM UTC

Hi Scott,

Thanks for your interest in Syncfusion products.

Please find the following sample link which illustrates “Previously recognized keyword”.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ModifiedSample1072615319.zip

The sample code as follows.

void editControl1_CursorPositionChanged(object sender, EventArgs e)
{
ILexemLine line = this.editControl1.GetLine(this.editControl1.CurrentLine);

//Read all lexems in line
IList listofLexems = line.LineLexems;

//read current word(lexem)
ILexem currentLex = line.FindLexemByColumn(this.editControl1.CurrentColumn);

//If current word is select or from, it return.
if(currentLex.Config.Format.Name=="KeyWord")
return;

string returnStr = string.Empty;

foreach (Lexem lex in listofLexems)
{
if (lex.Column > currentLex.Column)
{
break;
}
if (lex.Config.Format.Name == "KeyWord" && lex.Column < currentLex.Column)
{
returnStr = lex.Text;
}
}

if (returnStr != string.Empty)
{
Console.WriteLine("ReturnStr:" + returnStr);
MessageBox.Show("Keyword is:" + returnStr);
}

}

Please let me know if you need further assistance.

Thanks,
Karikalan N


SB Scott Blood May 12, 2010 01:02 PM UTC

Karikalan,

Thanks for your post. However i have an issue with this code.

Firstly, the code only searches on the currently line for the last identified keyword, what if the user is on another line??? have do i ensure that the search goes backwards to the last found keyword, regardless of what line the user is on.

Secondly you actually have helped me by pointing me in the direction of a nasty bug i had implemented and not thought of, if a user is currently over a keyword, you dont want the system popping up intellisense for the previous keyword, so thankyou very much for this.

If you could help me a little further i am sure within the near future i will be putting an order in for a number of licenses for your complete component suite.
Thanks


KN Karikalan Natarajan Syncfusion Team May 13, 2010 08:33 AM UTC

Hi Scott,

Thank you for your inquiry. We appreciate the opportunity to assist you.

Here is the sample application which illustrates your expected behavior "the search goes backwards to the last found keyword"

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ModifiedSample2056986894.zip

In the sample, if a cursor is in start of the word or within the word, the search goes backwards to last found keyword like Select,from,etc.,

Please post the queries in Direct-Trac. You will get a faster response along with an automatic update when your question is answered via Direct-Trac. We are happy to assist you.

Here is the Direct-Trac link.

https://www.syncfusion.com/Support/DirectTrac/logon.aspx?URL=/Support/DirectTrac/default.aspx

Please let me know if you need further information on this.

Thanks,
Karikalan N

Loader.
Live Chat Icon For mobile
Up arrow icon