5

I'm working on an addin for Visual Studio 2008 and want to add a permanent submenu to contain my context-sensitive commands to several context menus (such as "Project", "Item", ...).

I have had no problem adding this submenu to the top of the context menu or to the bottom of it. I'm using:

 mPlugin.Commands.AddCommandBar(_MenuName, vsCommandBarType.vsCommandBarTypeMenu, commandBar, desiredSubmenuPosition); /*desiredSubmenuPosition = 1 or desiredSubmenuPosition = commandBar.Controls.Count+1 work perfectly fine.

However, I want to add my submenu right before the last separator of the context menu. To do this, I find all the controls that have BeginGroup to true and get the control that has the biggest Index. I then add my submenu to the found index-1 with the above method. But there is something wrong. For some context menus it works fine, for others it creates my submenu at the wrong place (I'm pretty sure I find the right index for insertion...).

Is there a proper way of doing this?

Nicolas
  • 51
  • 1
  • 1
    VS menus themselves change according to context. The index you get may be the static one. Checkout this powertoy, it'll help in debugging: http://archive.msdn.microsoft.com/VSCTPowerToy/Release/ProjectReleases.aspx?ReleaseId=698 – Mrchief Jul 09 '11 at 22:42
  • I installed the tool, but since my addin is not a VSPackage, it does not work. – Nicolas Jul 11 '11 at 14:26

0 Answers0