cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting a menu created on right click event

former_member211473
Contributor
0 Kudos
745

Dear Experts,

I have created a right click event to add a menu option

Application.SBO_Application.RightClickEvent += new SAPbouiCOM._IApplicationEvents_RightClickEventEventHandler(SBO_Application_RightClickEvent);

It works fine and create 2 menu ON RIGHT CLICK. the menus are created only on one form(BOM).

Now I want to delete/remove the menu created when the form is closed, I have used item event but the system says "Menu - Unique ID not found"

private void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            if (((pVal.FormTypeEx == "672") && (pVal.EventType == SAPbouiCOM.BoEventTypes.et_F     ORM_CLOSE) && (pVal.Before_Action == true)))
            {
                Application.SBO_Application.MessageBox("form close event");
                try
                {
                    Application.SBO_Application.Menus.RemoveEx("menuOption1");
                    Application.SBO_Application.Menus.RemoveEx("menuOption2");
                }
                catch (Exception ex)
                {
                    Application.SBO_Application.MessageBox(ex.Message + "11");
                }
            }
         
        }

Can anyone please let me know how can i remove the menus??

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Ranu Vijay,

I didn't get your requirement. Why are you trying to remove the menus while the form is going to close?

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

former_member211473
Contributor
0 Kudos

Hi ankit.chauhan1

Because the menu once created can be seen on other form also. Though the menu can not be created from other form.

I don't need it everywhere.

Also If you could just let me know how to remove the method from delegate (-=, delegates) for right click event(any proper way). In my form close item event, I am not able to do that also for right click event.(it makes it do things multiple time, depending upon the number of times I close and open the same form)

Regards

former_member211473
Contributor
0 Kudos

Dear ankit.chauhan1

Thanks for your interest in my issue.

I have successfully achieved all my needed functionality.

I missed a lot of points in my above code and now i know better event handling.

Hope to see you again helping us do more.

Regards

Ranu Vijay