method Context.Add (HTMLItem as String, [Item as Variant], [Image as Variant], [SortOrder as Variant])
Adds a new item to the control's context list.

 TypeDescription 
   HTMLItem as String A string expression that identifier the item's caption in the context popup list. Built-in HTML tags are accepted as well.    
   Item as Variant A string expression that indicates the keyword typed when user selected the item from the context popup list.  
   Image as Variant A long expression that indicates the index of image in the item.  
   SortOrder as Variant A long expression that indicates the order of the item if the list gets sorted.  

Use the Add method to add new items to the control's context collection. The control provides a collection called Context that helps you to add new items to context drop down portion. You can invoke the drop down context window, by pressing CTRL+SPACE. If you want to provide icons for items in the drop down portion, you have to use the Images method. Use the Sort method to get the items sorted. You can use the OnContext event to add new items to the Context collection when user invokes the control's context window.

The following VB sample adds few items to control's drop down portion:

With Edit1.Context("")
    .Add "<fgcolor=FF0000>class</fgcolor>", , 1
    .Add "<fgcolor=0000FF><b>public</fgcolor>", , 2
    .Add "<fgcolor=0000FF><b>protected</fgcolor>"
    .Add "<fgcolor=0000FF><b>private</fgcolor>", , 3
End With

The following C++ sample adds few items to the control's drop down portion:

#include "Context.h"
COleVariant vtMissing; vtMissing.vt = VT_ERROR;
CContext context = m_edit.GetContext( vtMissing );
context.Add("<fgcolor=FF0000>class</fgcolor>", vtMissing , COleVariant( long(1) ), vtMissing );
context.Add("<fgcolor=0000FF><b>public</fgcolor>", vtMissing , COleVariant( long(2) ), vtMissing );
context.Add("<fgcolor=0000FF><b>protected</fgcolor>", vtMissing , vtMissing, vtMissing );
context.Add("<fgcolor=0000FF><b>private</fgcolor>", vtMissing , COleVariant( long(3) ), vtMissing );

The following VB.NET sample adds few items to the control's drop down portion:

With AxEdit1.get_Context("")
    .Add("<fgcolor=FF0000>class</fgcolor>", , 1)
    .Add("<fgcolor=0000FF><b>public</fgcolor>", , 2)
    .Add("<fgcolor=0000FF><b>protected</fgcolor>")
    .Add("<fgcolor=0000FF><b>private</fgcolor>", , 3)
End With

The following C# sample adds few items to the control's drop down portion:

EXEDITLib.Context context = axEdit1.get_Context("");
context.Add("<fgcolor=FF0000>class</fgcolor>", null , 1, null );
context.Add("<fgcolor=0000FF><b>public</fgcolor>", null , 2, null);
context.Add("<fgcolor=0000FF><b>protected</fgcolor>", null, null, null);
context.Add("<fgcolor=0000FF><b>private</fgcolor>", null, 3, null);

The following VFP sample adds few items to the control's drop down portion:

With thisform.Edit1.Context("")
    .Add("<fgcolor=FF0000>class</fgcolor>", , 1)
    .Add("<fgcolor=0000FF><b>public</fgcolor>", , 2)
    .Add("<fgcolor=0000FF><b>protected</fgcolor>")
    .Add("<fgcolor=0000FF><b>private</fgcolor>", , 3)
EndWith

 

 


Send comments on this topic.
1999-2008 Exontrol Inc, Software. All rights reserved.