This section describes how you customize an existing context menu by adding a new menu item
The example is using the steps described in A Simple Client Customization as base, followed by additional steps for adding the column.
A Simple Client Customization getting a customized form window named tbwCustomerInfoOverview_Cust.
Note: Customize the tbwCustomerInfoOverview table window instead of frmPersonInfo form window which is used for example above
private void cmd_Execute(object sender, Fnd.Windows.Forms.FndCommandExecuteEventArgs e) { e.Handled = true; FndMessageBox.Show("Started cmd_Execute!", "My Customization"); }
Example: Shows how the customized menu item is appended to the bottom of the
core context menu (after the Details menu item)
Your menu item named Show should be listed at the bottom of the context menu.
Customized menu items can only only be appended to existing context menus by
being created as items in a new context using the same name as the
original menu + the layer name
<MenuName>_<LayerName>
Example:
The core form have a menu named menuFrmMethods with three menu items:
Open, Release & Close You want to customize it by adding a
fourth menu item named Cancel.
In the customized form, do the following:
The framework will "merge" all the context menus in runtime, using the layer order (First Core, then Ext, last Cust)
The design time support in Visual Studio don't allow repositioning of menu items that are partly designed in the Core form and partly designed in the Cust/Ext form. The framework will automatically merge these partly defined menus, showing their items starting with the Core menu items, followed by the Ext menu items and finally the Cust menu items.
Situations where you need to rearrange menu items and have your Cust/Ext items placed in locations before/after items hosted inside the Core menu, can be solved by using a suite of dedicated methods introduced in the framework.
Example:
Core form: holds the menu menuFrmMethods
containing five menu items: menuItemValid, menuItemInvalid,
menuSeparator1, menuItemUsedByGroups & menuItemCopyFormula
Cust form: holds the menu menuFrmMethods_Cust
containing three menu items: menuItemCustom1, menuItemCustom2 &
menuItemCustom3
Example:
The Command Manager designer showing both menus
By default, both menus will be merged by the framework just before they are
shown, with following result:
To change an item location, override the method OnRearrangeMergedMenuItems and call one of the FndContextMenuStrip methods:
Listed methods will move the specified item/items to a position that is before or after a specific item.
protected override void OnRearrangeMergedMenuItems(FndContextMenuStrip contextMenu) { base.OnRearrangeMergedMenuItems(contextMenu); // Move the second menu item "menuItemCustom2" defined in menu "menuFrmMethods_Cust" // to the location just after the menu item "menuItemValid" which is defined in menu "menuFrmMethods". contextMenu.MoveItemAfter(this.menuItemCustom2, this.menuItemValid); }
The example above will result in a menu having its menu item
Custom 2 moved to the location just
after the menu item Valid.
The listed methods are overloaded and can move
to a location before/after a targeted context menu item.
The targeted item can be an item hosed in a sub-menu.
Moving a sub-menu item to a targeted item location will automatically move all its child items.