开发者

Is there some way to collapse folders recursively in the Visual Web Developer 2010 Express Solution Explorer?

开发者 https://www.devze.com 2023-03-14 09:45 出处:网络
This is something I want to do quite often, as I end up with hundreds of source files visible in Solution Explorer and things can get quite confusing.

This is something I want to do quite often, as I end up with hundreds of source files visible in Solution Explorer and things can get quite confusing.

I have found several extensions which will do this in Visual Studio, but as Visual Web Developer 2010 Express doesn't support extensions I'm looking for an alternative solution.

Any suggestions gratefully received!

Edit: In case it wasn't clear from the question title, I want to collapse folders recursively, not just hide the expan开发者_C百科ded sub-tree and have it show in the same state when I open the parent folder again.


If you double click on a folder, that folder gets collapsed, but not the folders inside the one you clicked. I think, you may not need as you do not get to see those folders inside the one you clicked as they are hidden inside the collapsed folder.


does this macro help?

http://kylefinley.net/archive/2006/02/02/37.aspx

Imports EnvDTE
Imports System.Diagnostics

Public Module Personal

Sub CollapseAll()

'DESCRIPTION: Collapse all the nodes in the project tree

' Get the the Solution Explorer tree
Dim oSolutionExplorer As UIHierarchy
oSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()

' Check if there is any open solution
If (oSolutionExplorer.UIHierarchyItems.Count = 0) Then
Return
End If

' Get the top node (the name of the solution)
Dim oRootItem As UIHierarchyItem
oRootItem = oSolutionExplorer.UIHierarchyItems.Item(1)
Dim oChildItem As UIHierarchyItem

' Collapse each project node
For Each oChildItem In oRootItem.UIHierarchyItems
CollapseMe(oChildItem, oSolutionExplorer)
Next

' Select the solution node, or else when you click on the solution window
' scrollbar, it will synchronize the open document with the tree and pop
' out the corresponding node which is probably not what you want.
oRootItem.Select(vsUISelectionType.vsUISelectionTypeSelect)

End Sub


Sub CollapseMe(ByVal oRootItem As UIHierarchyItem, ByVal oSolutionExplorer As UIHierarchy)

Dim oChildItem As UIHierarchyItem

For Each oChildItem In oRootItem.UIHierarchyItems
CollapseMe(oChildItem, oSolutionExplorer)
Next

oRootItem.UIHierarchyItems.Expanded = False 

' Added to deal with the Visual Studio bug
If (oRootItem.UIHierarchyItems.Expanded = True) Then
oRootItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
oSolutionExplorer.DoDefaultAction()
End If

End Sub

End Module


Ok, after five months I'm assuming there just isn't a way to do this. Marking as answered.

0

精彩评论

暂无评论...
验证码 换一张
取 消