.NET Customisation
User Guide
.NET Customisation
:
AVEVA C# Grid Control
: Add an XML Menu to the Form
Add an XML Menu to the Form
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 Customisation utility described earlier in this document.
To add the menus you will need to do the following in the Menu Customisation utility:
1.
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 Customisation 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.RootTools[contextMenuKey];
mAddinControl.SelectionMenu = menu;
}
contextMenuKey = "NewAddin.HeaderMenu";
if
(mCommandBarManager.RootTools.Contains(contextMenuKey))
{
MenuTool menu = (MenuTool)mCommandBarManager.RootTools[contextMenuKey];
mAddinControl.HeaderMenu = menu;
}
}
2.
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.
3.
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.
4.
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.
5.
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.
6.
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.
1974 to current year.
AVEVA Solutions Limited and its subsidiaries. All rights reserved.