Type | Description | |||
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 |
private void ExecuteContextMenu(object sender, AxEXPRESSIONLib._IExpressionEvents_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: AxEXPRESSIONLib._IExpressionEvents_ExecuteContextMenuEvent); begin end; begin event ExecuteContextMenu(string Item,long Position) end event ExecuteContextMenu Private Sub ExecuteContextMenu(ByVal sender As System.Object, ByVal e As AxEXPRESSIONLib._IExpressionEvents_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(oExpression,Item,Position) RETURN |
<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 Expression1 .AllowContextMenu = True .ContextMenuItems = vbCr & "Item 1" & vbCr & vbCr & "Item 2" & vbCr & "Item 3" End With End Sub
Private Sub Expression1_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 OnExecuteContextMenuExpression1(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 AxExpression1 .AllowContextMenu = True .ContextMenuItems = vbCr & "Item 1" & vbCr & vbCr & "Item 2" & vbCr & "Item 3" End With
Private Sub AxExpression1_ExecuteContextMenu(ByVal sender As Object, ByVal e As AxEXPRESSIONLib._IExpressionEvents_ExecuteContextMenuEvent) Handles AxExpression1.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:
axExpression1.AllowContextMenu = true; axExpression1.ContextMenuItems = "\rItem1\r\rItem2\rItem3";
private void axExpression1_ExecuteContextMenu(object sender, AxEXPRESSIONLib._IExpressionEvents_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.Expression1 .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