Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Menu

HI

How to Add the Menu.Not a menu item.if u have a code then send me.

replied

Hi,

altough there should be already hundreds of samples in this forum i post

a c# code snippet how to add a menu with menuitems:

        SAPbouiCOM.Menus oMenus = null;
        SAPbouiCOM.MenuItem oMenuItem = null;

        // Get the menus collection from the application
        oMenus = globals.SBO_Application.Menus;

        SAPbouiCOM.MenuCreationParams oCreationPackage = null;
        oCreationPackage = ((SAPbouiCOM.MenuCreationParams)(globals.SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)));
        oMenuItem = globals.SBO_Application.Menus.Item("43520"); // modules'

        string sPath = null;
        sPath = System.IO.Directory.GetParent(Application.ExecutablePath).ToString();

        // find the place in wich you want to add your menu item
        // in this example I chose to add my menu item under
        // SAP Business One.
        oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP;
        oCreationPackage.UniqueID = "Project01";
        oCreationPackage.String = "YourMenuName";
        oCreationPackage.Enabled = true;
        //oCreationPackage.Image = sPath + "\\b1_14x18.bmp";
        oCreationPackage.Position = 15;

        oMenus = oMenuItem.SubMenus;        

         //  If the manu already exists this code will fail
         oMenus.AddEx(oCreationPackage);

         // Get the menu collection of the newly added pop-up item
         oMenuItem = globals.SBO_Application.Menus.Item("Project01");
         oMenus = oMenuItem.SubMenus;

         // Create s sub menu
         oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING;
         oCreationPackage.UniqueID = "Entry1";
         oCreationPackage.String = "YourMenuItemName"
         oMenus.AddEx(oCreationPackage);

lg David

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question