![]() | 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.
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 SubPrivate 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 SubThe 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 WithPrivate Sub AxEdit1_ExecuteContextMenu(ByVal sender As Object, ByVal e As AxEXEDITLib._IEditEvents_ExecuteContextMenuEvent) Handles AxEdit1.ExecuteContextMenu
Debug.WriteLine(e.item)
End SubThe 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