Create shortcut key to collapse dot net Solution
In this article we must be aware that we can expand the whole tree of TreeView Control by selecting the parent node and pressing the ‘*’ on the Num Key Pad.
Imports EnvDTE Imports System.Diagnostics Public Module CollapseAllChildNodes Sub CollapseAllChildNodes() ' This is to get the the Solution Explorer tree Dim _objUIHierarchy As UIHierarchy _objUIHierarchy = DTE.Windows.Item( _ Constants.vsext_wk_SProjectWindow).Object() ' This one is to check if there is any open solution If (_objUIHierarchy.UIHierarchyItems.Count = 0) Then Return End If ' And finally to Get the top node (the name of the solution) Dim _objUIHierarchyItem As UIHierarchyItem _objUIHierarchyItem = _objUIHierarchy.UIHierarchyItems.Item(1) ' Heres the final one to collapse each project node Dim _objCurrUIHierarchyItem As UIHierarchyItem For Each _objCurrUIHierarchyItem In _objUIHierarchyItem.UIHierarchyItems _objCurrUIHierarchyItem.UIHierarchyItems.Expanded = False Next ' To leave you back onto the Node you had selected _objUIHierarchyItem.Select(vsUISelectionType.vsUISelectionTypeSelect) End Sub End ModuleIntroduction
But there is no way you can collapse all the projects and since we have so many projects in TISSIP please don't waste so much time in closing each of the project in solution explorer one by one.
So here is one more shortcut form your Shortcut Guru.
Try the following approach instead.
1> Open up the Macro Explorer (Alt-F8)
2> Add a module to my “MyMacros" macro project,.
3> Call the module “CollapseAllChildNodes" and modify the whole of the default module with this code:
4> Assign a shortcut key to it by ToolsàOptionsàEnvironmentàKeyboard settings
5> Now the show commands containing “Macros" should have the sub procedure we just created.
6> Click in the press shortcut keys and assign the shortcut by actually pressing 'Ctrl-Shift-*'. (* from the NUMLOCK KeyPad)