locked
VS2012, Add-In: How to add a Solution Explorer context menu-item? RRS feed

  • Question

  • Hi,

    I need to create a new menu-item on the Solution Explorer right-click context menu. And I need to currently selected item (folder or file) path.

    I have used MZ-Tools pages with success until now (adding menu-item to code context menu), but I can't seem to find the Solution Explorer context menu. The commandBars contains the "Project and Solution Context Menus" but nothing happens if I add to this menu.

    Any hints on how to achieve this? How to reference the correct menu and how to get the selected item?

    --
    Werner




    Monday, February 18, 2013 9:44 AM

Answers

  • Hi,

    I have another MZ-Tools page for that:

    HOWTO: Guessing the name of a command bar to add a custom menu entry in Visual Studio .NET add-ins.
    http://www.mztools.com/articles/2004/MZ2004002.aspx

    You have all of them here:

    http://www.mztools.com/resources_vsnet_addins.aspx

    About the other question, the Solution Explorer is multi-selection and cross-selection (that is, several selected items of different kinds -solution, project, file...-, and from different projects). To get the selected items you can use:

    - EnvDTE.DTE.SelectedItems property. For each EnvDTE.SelectedItem, the Project and ProjectItem properties give you if the item is a file, a project or something else (the solution node).

    - Alternatively, you can get the UIHierarchy of the Solution Explorer (see http://www.mztools.com/articles/2006/MZ2006015.aspx) and for each UIHierarchyItem you have the kind (Object property) and if it is selected (IsSelected property)


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    Monday, February 18, 2013 3:19 PM

All replies

  • Got it, the menu is called "Solution" :)

    Now I just need to get the item selected in the solution Explorer..?

    --
    Werner

    Monday, February 18, 2013 10:24 AM
  • Hi,

    I have another MZ-Tools page for that:

    HOWTO: Guessing the name of a command bar to add a custom menu entry in Visual Studio .NET add-ins.
    http://www.mztools.com/articles/2004/MZ2004002.aspx

    You have all of them here:

    http://www.mztools.com/resources_vsnet_addins.aspx

    About the other question, the Solution Explorer is multi-selection and cross-selection (that is, several selected items of different kinds -solution, project, file...-, and from different projects). To get the selected items you can use:

    - EnvDTE.DTE.SelectedItems property. For each EnvDTE.SelectedItem, the Project and ProjectItem properties give you if the item is a file, a project or something else (the solution node).

    - Alternatively, you can get the UIHierarchy of the Solution Explorer (see http://www.mztools.com/articles/2006/MZ2006015.aspx) and for each UIHierarchyItem you have the kind (Object property) and if it is selected (IsSelected property)


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    Monday, February 18, 2013 3:19 PM
  • I know now that msdn documentation doesn't link to your pages - but they should. Thanks again.
    Tuesday, February 19, 2013 7:10 AM
  • There used to be a Community Section in the MSDN docs where I added links to my pages but that section was removed for VS 2012.

    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    Tuesday, February 19, 2013 1:20 PM