2

这是我经常想做的事情,因为我最终会在解决方案资源管理器中看到数百个源文件,并且事情会变得非常混乱。

我在 Visual Studio 中找到了几个可以执行此操作的扩展,但由于 Visual Web Developer 2010 Express 不支持扩展,我正在寻找替代解决方案。

任何建议都感激不尽!

编辑:如果问题标题不清楚,我想递归折叠文件夹,而不仅仅是隐藏展开的子树并在我再次打开父文件夹时让它以相同的状态显示。

4

3 回答 3

0

如果您双击一个文件夹,该文件夹会折叠,但您单击的文件夹内的文件夹不会折叠。我认为,您可能不需要,因为您无法在单击的文件夹中看到这些文件夹,因为它们隐藏在折叠的文件夹中。

于 2011-06-22T08:21:38.567 回答
0

这个宏有帮助吗?

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
于 2011-08-31T10:11:49.223 回答
0

好的,五个月后,我假设没有办法做到这一点。标记为已回答。

于 2011-12-02T07:56:52.230 回答