Use the Minimize Solution extension. This feature usually comes with ReSharper , but I assume you are not using ReSharper.
There are also many macros to help you do the same. One of them is in Collapse All in Visual Studio .
Note. There is no built-in way in Visual Studio to actually achieve this. And considering how practical this is, I would think that they would add this feature to Visual Studio 2005. I know that people have been asking for this for many years. But in its infinite wisdom, Microsoft does not consider this important enough.
source share