Add an XML Menu to the Form
- Last UpdatedJun 02, 2022
- 2 minute read
Code has been added to the supplied addin to allow two different context menus to be used with the grid: a selection menu, and a header menu.
To enable this to work with your session you will need to use the Menu Customization utility described earlier in this document.

To add the menus you will need to do the following in the Menu Customization utility:
-
Add a new Context Menu, which has its name property set to: NewAddin.SelectMenu. This name is used by the code to locate the set of menus to display when the user makes a context menu selection on one or more equipment items in the grid. The C# method below from the addin class, is the code which loads the menu. The menus which you create in the Menu Customization Utility will be stored in the Design.uic file.

private void mCommandBarManager_UILoaded(object sender, EventArgs e)
{
String contextMenuKey = "NewAddin.SelectMenu";
if(mCommandBarManager.RootTools.Contains(contextMenuKey))
{
MenuTool menu = (MenuTool)mCommandBarManager.Root\-Tools[contextMenuKey];
mAddinControl.SelectionMenu = menu;
}
contextMenuKey = "NewAddin.HeaderMenu";
if(mCommandBarManager.RootTools.Contains(contextMenuKey))
{
MenuTool menu = (MenuTool)mCommandBarManager.Root\-Tools[contextMenuKey];
mAddinControl.HeaderMenu = menu;
}
}
-
Create a button and set the command to AVEVA.DrawList.Add. When this menu is used in the Addin it will add the selected equipment item(s) to the 3D view.
-
Assign the button to the context menu named NewAddin.SelectMenu. You can create other menu options (either from existing commands which have been exposed, or from existing PML methods and functions) in the same way and assign these to the context menu.
-
Create a second Context menu named NewAddin.HeaderMenu. This name is used by the code to locate the set of menus to display when the user makes a context menu selection on the header bar in the grid.
-
Create a button and set the command to AVEVA.Grid.ExportToExcel. When this menu is used in the Addin it will export the grid data to a Microsoft Excel file.
-
Assign the button to the context menu named NewAddin.HeaderMenu. You can create other menu options in the same way and assign these to the context menu.