Create your own Right click menu on a Sales Order

Paolo Manfrin

The following code snippet shows you how to create your own menu when right clicking on a matrix row number:




newMenu.AddHandler_Click(delegate(SwissAddonFramework.UI.EventHandling.MenuEvents.MenuClick e)
{
MessageBox.Show("Menu clicked", "OK");
});
// Enable the menu on the sales order matrix
Form.AddHandler_Load("139", ModeComponent.FormModes.ALL, delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.FormLoad e)
{
MenuItem dataMenu = MenuItem.GetFromUID("1280");
MenuItem newMenu = MenuItem.CreateNew("NEWMENU1");
newMenu.Value = "New Menu Item";
newMenu.Type = MenuItem.MenuType.String;
dataMenu.SubMenus.AddMenuItem(newMenu);
dataMenu.Load();
Matrix matrix = Matrix.GetFromUID(e.Form, "38");
matrix.Columns[0].AddHandler_RightClick(
delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.RightClick e2)
{
MenuItem.GetFromUID("NEWMENU1").Enabled = true;
},
delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.RightClick e2)
{
MenuItem.GetFromUID("NEWMENU1").Enabled = false;
});
});


TodAnderson

Hi Paolo,


 


I have used your code in an own form, and it works very nicely... except, it executes several times.


 


if I close SAP, then open the form and execute the right click it runs once. good!


close just the form, then reopen it and execute the right click again and it runs twice.. repeat, three times... and so on till I close SAP and start over.


 


Any ideas why?



Paolo Manfrin

Hi, yes


because every time you are actually registering a new event :-)


 


Try with matrix.Columns[0].RemoveAllHandlers() before calling matrix.Columns[0].AddHandler_RightClick(...)


 


hth


paolo



TodAnderson

Thanks



0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post