Modifying the Item Context Menu
I was trying to implement an AddIn that modified the context menu for project items. Specifically, C# files. After poking around for a couple of hours, I succeeded. Adding a menu item (or CommandBarControl) is relatively simple. What was complicated was adding it to the right context menu.
In my case, the menu I wanted was the Item menu. So you do this with the following code
CommandBar cbar = (GlobalInstanceCache.MainApplication.CommandBars as CommandBars)["Item"];
CommandBarControl ctrl = cbar.Controls.Add(MsoControlType.msoControlButton, Missing.Value, Missing.Value, 1, true) as CommandBarControl;
ctrl.Caption = "My Ctx Menu Command";
That worked.