VS Macro to Locate Solution Explorer Item – Corrected
Posted by Dan Vanderboom on April 8, 2008
A few weeks ago, I posted an article about a Visual Studio macro (with source code) to locate and select an item in Solution Explorer corresponding to the active document. I discovered that Solution Explorer loads its UIHierarchy items on demand, so items only become available in thet tree structure if their parent node has been expanded.
The key to solving this was a single line of code:
This forces Solution Explorer to load the necessary items and also expands the tree so that the item becomes visible. After that, selecting the item becomes possible.
I’ve updated the original article to correct the source code, and from what I can tell from more extensive testing, it seems to work all the time now.