method Edit.AddKeyword (Keyword as String, [Tooltip as Variant], [TooltipTitle as Variant], [CaseSensitive as Variant])
Adds a keyword to a sensitive control.

 TypeDescription 
   Keyword as String A string expression that defines the keyword being added. The Keyword parameter may include built-in HTML tags.  If the first character in the Keyword parameter is ^, it indicates that the keyword should be at the beginning of the line, else it is ignored.  
   Tooltip as Variant Optional. A string expression that indicates the keyword's description. The tooltip is displayed when cursor is over the keyword.  The Tooltip supports HTML format too. You can use the QueryContext / QueryContextToolTip events to display a different tooltip for the same keyword.  
   TooltipTitle as Variant Optional. A string expression that indicates the title of keyword's tooltip. You can use the QueryContext / QueryContextToolTip events to display a different tooltip for the same keyword.  
   CaseSensitive as Variant Optional. The CaseSensitive parameter is of  KeywordSensitiveEnum type. A long expression that indicates the type of the start and end expressions. The valid values are 0 - exCaseSensitiveKeyword, 1 - exNonCaseSensitiveKeyword and 2 - exReplaceKeyword. By default, the CaseSensitive parameter is 0 (exCaseSensitiveKeyword)  
Use the AddKeyword method to add keywords to a sensitive control. The AddKeyword method has effect if the control's EditType property is exSensitive. Use the AddExpression method to add expression to your sensitive control (an expression starts with something and ends with something ).  Use the AddWild method to define expression that contains wild characters like: * or ?. Use the MarkColor property to mark ( on the control's vertical scroll bar ) the positions of the keywords in the control's text. Use the FormatNumbers property to specify the format of the numbers in the control. Use the ToolTipOnTyping property to display the keyword's tooltip while typing in the control. The AllowInlineToolTip property indicates that the current line shows inline tooltip for keywords found to the caret.

The list of supported built-in HTML tags are:

Use the DeleteKeyword method to remove a particular keyword. If the Keyword parameter contains only HTML tags and no text, the control will not add the keyword. 

The Tooltip parameter supports the following built-in HTML tags:

For instance the following sequence: AddKeyword("<b></b>") wont add any new keyword. Instead AddKeyword("<b>public</b>") will add the "public" keyword.

Here's few samples how to define keywords:

If you are adding a temporary keyword, the Refresh method should be called, to let control reflects the changes in the visible area.

The following VB sample adds a case sensitive keyword ( the exCaseSensitiveKeyword is not required, because the AddKeyword adds by default a case sensitive keyword ) :

With Edit1
        .AddKeyword "<fgcolor=0000FF><b>class</b></fgcolor>", "Defining a case sensitive keyword.", "Case Sensitive", exCaseSensitiveKeyword
End With

In this case, if you are tying 'class', 'ClaSs', 'clasS' and so on, it will be highlighted as 'class', 'ClaSs', 'clasS', and so on. The exCaseSensitiveKeyword constant is 0

The following VB sample adds a non case sensitive keyword:

With Edit1
        .AddKeyword "<fgcolor=0000FF><b>class</b></fgcolor>", "Defining a non case sensitive keyword.", "Non Case Sensitive", exNonCaseSensitiveKeyword
End With

In this case, if you are tying 'class', 'ClaSs', 'clasS' and so on, it will be highlighted as 'class', 'ClaSs', 'clasS', and so on. The exNonCaseSensitiveKeyword constant is 1

The following VB sample adds a non case sensitive keyword, but any occurrence of the keyword in the text will be displayed as it is defined:

With Edit1
        .AddKeyword "<fgcolor=0000FF><b>class</b></fgcolor>", "Defining a non case sensitive keyword.", "Non Case Sensitive", exReplaceKeyword
End With

In this case, if you are tying 'class', 'ClaSs', 'clasS' and so on, it will be highlighted as 'class', 'class', 'class', and so on. The exReplaceKeyword constant is 2

The following C++ sample adds a case sensitive keyword:

m_edit.AddKeyword("<fgcolor=0000FF><b>class</b></fgcolor>", COleVariant( "Defining a case sensitive keyword." ), COleVariant( "Case Sensitive") , COleVariant( (long)0 /*exCaseSensitiveKeyword*/ ) );

The following VB.NET sample adds a case sensitive keyword:

With AxEdit1
    .AddKeyword("<fgcolor=0000FF><b>class</b></fgcolor>", "Defining a case sensitive keyword.", "Case Sensitive", EXEDITLib.KeywordSensitiveEnum.exCaseSensitiveKeyword)
End With

The following C# sample adds a case sensitive keyword:

axEdit1.AddKeyword("<fgcolor=0000FF><b>class</b></fgcolor>", "Defining a case sensitive keyword.", "Case Sensitive", EXEDITLib.KeywordSensitiveEnum.exCaseSensitiveKeyword);

The following VFP sample adds a case sensitive keyword:

With thisform.Edit1
        .AddKeyword("<fgcolor=0000FF><b>class</b></fgcolor>", "Defining a case sensitive keyword.", "Case Sensitive", 0) && exCaseSensitiveKeyword
endwith
  

 


Send comments on this topic.
1999-2016 Exontrol.COM, Software. All rights reserved.