Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How to Change Order of a Flavored Project’s Item Nodes in Visual Studio Solution Explorer (VSPackage)?

$
0
0
As part of an extension for Visual Studio 2010/2012 (VSPackage) I need to change the order of a flavored project’s nodes in the solution explorer. Specifically, I have a custom project subtype that inherits from “Microsoft.VisualStudio.Shell.Flavor.FlavoredProjectBase”. I need to display several folders in a non-alphabetic order similar to “Properties” and “Referenced” coming first in a class library project. So, for example instead of the folders being displayed “FolderA, FolderB, FolderC” I need to programmatically arrange them as something like “FolderC, FolderA, Folder B”.

In this specific case, the folders are real, but I hoping to find a generic approach that would allow me to change the node order for whatever types of nodes (such as a virtual folder) that I end up needing to complete the extension.

Two possible approaches that I have explored without success are:

1. Override “GetProperty(uint itemId, int propId, out object property)” in the flavored project and return a rearranged ItemId for the __VSHPROPID.VSHPROPID_FirstChild, _VSHPROPID.VSHPROPID_FirstVisibleChild, __VSHPROPID.VSHPROPID_NextSibling, and __VSHPROPID.VSHPROPID_NextVisibleSibling properties.

In this case if I did not rearrange the ItemIds and returned the nodes in the same order, everything worked. As soon as I returned the nodes in a different order it failed.

2. Changing the order of nodes through ToolWindows.SolutionExplorer’s UIHierarchy. The 2003 MSDN documentation talks about being able to move nodes. Later versions talk about moving the insertion point. It is straight forward to find the project’s UIHierarchyItem object from the flavored project, but there does not appear to be a way to change the node order.

I must be missing something. This should be very simple to achieve.

How can I change the order of a project’s item nodes in a flavored project subtype?

Viewing all articles
Browse latest Browse all 4410

Trending Articles