Changing font or icon of item in solution explorer

Adam Jachocki 46 Reputation points
2020-12-15T13:50:54.537+00:00

Hi, I am creating simple VSIX. Some projects (vcxproj) could have special meanings (for example: "A project with models") and I would like to mark them in Solution Explorer somehow. So first I thought that I would change font color of the project and bold it. As far as I could find some way to make it bold, I am not able to find anything that could change the color of item in solution explorer.

So is there any way to do this? Or maybe there is a way to ADD an icon near the item in solution explorer?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,893 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,106 Reputation points Microsoft Vendor
    2020-12-16T08:32:00.063+00:00

    Hello @AdamJachocki-5815 ,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    I think your requirement is like right-clicking one of the projects in your solution, and in the shortcut menu select one “option” and this project will be marked.

    To add a button in shortcut menu of project(by right-clicking project), you can refer to this document: Add a command to the Solution Explorer toolbar(Add a button to the Solution Explorer toolbar), since this document indicates that add a button to the Solution Explorer toolbar, you can refer to this document: IDE-Defined Commands for Extending Project Systems(Shortcut Menus) and modify the IDM_VS_TOOL_PROJWIN to IDM_VS_CTXT_PROJNODE to let this button displays in right-click shortcut menu.

    And for the detailed logic of marking the specified project, you need to write the related codes in .cs(if you use C#) file which you added to your VSIX project as a menu command item template(For this sample is ToolbarButton.cs file). Focus on the Execute() method, and write your codes there, this function is the callback used to execute the command when the menu item is clicked.

    Besides, I think you will need to check these APIs: Visual Studio SDK API Reference version 2019.

    I hope this could help you a little.

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments

  2. Jonathan Isabelle 1 Reputation point
    2023-07-30T14:57:58.8033333+00:00

    In iterating the list of IVsHierarchyItems, there are only two properties with setters: IsBold and IsCut. The good news is these both affect the appearance of the item in Solution Explorer. IsBold makes the project bold like setting the active project would and IsCut makes the project appear dimmed as if you had performed a "cut" operation on it.User's image

    For my purposes, I didn't like either of these options and am still looking for a way to show an icon next to each project in Solution Explorer. I thought I'd mention these two options for you in case you're looking for something like that.

    0 comments No comments