event ExecuteContextMenu (Item as String, Position as Long)
Occurs when the user selects an user item from the control's context menu.

TypeDescription
Item as String A string expression that indicates the selected item.
Position as Long A long expression that indicates the position of the selected item. The Position is 1 based, and the separator items do not count.

The ExecuteContextMenu event notifies your application that the user selects a custom context menu item. Use the ContextMenuItems property to add custom items to the control's context menu. Use the AllowContextMenu property  to allow the control's context menu. The ExecuteContextMenu event is not fired if the user selects one of the default entries in the control's context menu such us: Undo, Copy, and so on.

Syntax for ExecuteContextMenu event, /NET version, on:

private void ExecuteContextMenu(object sender,string Item,int Position)
{
}

Private Sub ExecuteContextMenu(ByVal sender As System.Object,ByVal Item As String,ByVal Position As Integer) Handles ExecuteContextMenu
End Sub

Syntax for ExecuteContextMenu event, /COM version, on:

private void ExecuteContextMenu(object sender, AxEXEDITLib._IEditEvents_ExecuteContextMenuEvent e)
{
}

void OnExecuteContextMenu(LPCTSTR Item,long Position)
{
}

void __fastcall ExecuteContextMenu(TObject *Sender,BSTR Item,long Position)
{
}

procedure ExecuteContextMenu(ASender: TObject; Item : WideString;Position : Integer);
begin
end;

procedure ExecuteContextMenu(sender: System.Object; e: AxEXEDITLib._IEditEvents_ExecuteContextMenuEvent);
begin
end;

begin event ExecuteContextMenu(string Item,long Position)
end event ExecuteContextMenu

Private Sub ExecuteContextMenu(ByVal sender As System.Object, ByVal e As AxEXEDITLib._IEditEvents_ExecuteContextMenuEvent) Handles ExecuteContextMenu
End Sub

Private Sub ExecuteContextMenu(ByVal Item As String,ByVal Position As Long)
End Sub

Private Sub ExecuteContextMenu(ByVal Item As String,ByVal Position As Long)
End Sub

LPARAMETERS Item,Position

PROCEDURE OnExecuteContextMenu(oEdit,Item,Position)
RETURN

Syntax for ExecuteContextMenu event, /COM version (others), on:

<SCRIPT EVENT="ExecuteContextMenu(Item,Position)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function ExecuteContextMenu(Item,Position)
End Function
</SCRIPT>

Procedure OnComExecuteContextMenu String llItem Integer llPosition
	Forward Send OnComExecuteContextMenu llItem llPosition
End_Procedure

METHOD OCX_ExecuteContextMenu(Item,Position) CLASS MainDialog
RETURN NIL

void onEvent_ExecuteContextMenu(str _Item,int _Position)
{
}

function ExecuteContextMenu as v (Item as C,Position as N)
end function

function nativeObject_ExecuteContextMenu(Item,Position)
return

The following VB sample adds some custom entries to the control's context menu, and prints the selected item, when the user selects it from the control's context menu:  

Private Sub Form_Load()
    With Edit1
        .AllowContextMenu = True
        .ContextMenuItems = vbCr & "Item 1" & vbCr & vbCr & "Item 2" & vbCr & "Item 3"
    End With
End Sub
Private Sub Edit1_ExecuteContextMenu(ByVal Item As String, ByVal Position As Long)
    Debug.Print "The user selects the '" & Item & "' item. The item's position is " & Position & "."
End Sub

The following C++ sample adds some custom entries to the control's context menu, and prints the selected item, when the user selects it from the control's context menu: 

m_edit.SetAllowContextMenu( TRUE );
CString strCustom( "\r" );
strCustom += "Item 1";
strCustom += "\r\r";
strCustom += "Item 2";
strCustom += "\r";
strCustom += "Item 3";
m_edit.SetContextMenuItems( strCustom );
void OnExecuteContextMenuEdit1(LPCTSTR Item, long Position) 
{
	OutputDebugString( Item );
}

The following VB.NET sample adds some custom entries to the control's context menu, and prints the selected item, when the user selects it from the control's context menu: 

With AxEdit1
    .AllowContextMenu = True
    .ContextMenuItems = vbCr & "Item 1" & vbCr & vbCr & "Item 2" & vbCr & "Item 3"
End With
Private Sub AxEdit1_ExecuteContextMenu(ByVal sender As Object, ByVal e As AxEXEDITLib._IEditEvents_ExecuteContextMenuEvent) Handles AxEdit1.ExecuteContextMenu
    Debug.WriteLine(e.item)
End Sub

The following C# sample adds some custom entries to the control's context menu, and prints the selected item, when the user selects it from the control's context menu: 

axEdit1.AllowContextMenu = true;
axEdit1.ContextMenuItems = "\rItem1\r\rItem2\rItem3";
private void axEdit1_ExecuteContextMenu(object sender, AxEXEDITLib._IEditEvents_ExecuteContextMenuEvent e)
{
	System.Diagnostics.Debug.WriteLine(e.item);
}

The following VFP sample adds some custom entries to the control's context menu, and prints the selected item, when the user selects it from the control's context menu:

with thisform.Edit1
	.AllowContextMenu = .t.
	.ContextMenuItems = chr(13) + "Item 1" + chr(13) + chr(13) + "Item 2" + chr(13) + "Item 3"
endwith
*** ActiveX Control Event ***
LPARAMETERS item, position

wait window nowait item