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.

Introduction


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:

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 Module


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)


Related Articles

Object Serialisation in dot net

This article provides an overview of the serialization used in Microsoft .NET and the usage of the same.For example, serialization is used to save session state in ASP.NET and to copy objects to the clipboard in Windows Forms. It is also used by remoting to pass objects by value from one application domain to another.

More articles: Dot Net

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: