I am developing an add-in for MS Project
in Visual Studio
and I need a custom menu item in the right click menu
. This will modify task data. I am using the following code to add a item:
private void AddMenuItem(String param)
{
Office.MsoControlType menuItem =
Office.MsoControlType.msoControlButton;
btn_editor =
(Office.CommandBarButton)app.CommandBars[param].Controls.Add
(menuItem, missing, missing, 1, true);
btn_editor.Style = Office.MsoButtonStyle.msoButtonCaption;
btn_editor.Caption = "My Menu Item";
btn_editor.Tag = "MyMenuItem";
btn_editor.Click +=
new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler
(editor_Click);
}
For String param I have used all the ComandBar names:
CommandBars commandBars = (CommandBars)app.CommandBars;
foreach (CommandBar cbar in commandBars)
{
AddMenuItem(cbar.Name);
}
All it did, was to add the button in the Ribbon in Addins Tab. No button was added in the right click menu. Do you know another way to add in right click menu?