Critical Development

Language design, framework development, UI design, robotics and more.

Locate Project Item in Solution Explorer – Improved

Posted by Dan Vanderboom on August 24, 2010

Way back in March 2008, I wrote an article sharing a macro to locate the current document in Solution Explorer without having to have the annoying setting “Track current item in Solution Explorer” always turned on.  I map this to my F1 key (I get my help online) and all is good in the world.

When I wrote this macro, I remember reading some documentation for VS2003 or VS2005 saying that it wasn’t possible to update this “Track current item” setting programmatically.  This has changed, and in VS2008 and VS2010 these can indeed be triggered programmatically.  Rob posted the much abbreviated code in one of the comments.

Public Sub TrackProjectItem()
    DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer", True)
    DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer", False)
    DTE.ExecuteCommand("View.SolutionExplorer")
End Sub

Thanks to Rob and all the others who left comments on that article.

Advertisements

One Response to “Locate Project Item in Solution Explorer – Improved”

  1. huaj said

    I found a problem in the macros above
    When solution is complex, that means nested solution folders, tens of projects,
    It seems the UIHierarchyItems is lazy load
    So, if some project is not expanded manually yet, it cannot be located

    Have some ideas on it?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: