11

In Visual Studio as most of you will have noticed that related file can be collapsed in to one. E.G.

  • Form1.cs
    • Form1.Designer.cs

I'm creating a DAL library and will be splitting partial classes in to several files such as:

  • SomeTableClass.cs
    • SomeTableClass.Generated.cs
    • SomeTableClass.SomethingElse.cs

Is there any way in Visual Studio to recognise these file are related to each other an create the collapsible effect?

Thanks

Tony

Kent Fredric
  • 56,416
  • 14
  • 107
  • 150
TWith2Sugars
  • 3,384
  • 2
  • 26
  • 43
  • 1
    For VS 2010 (version 10), use HKCU instead: [http://stackoverflow.com/questions/3046591/visual-studio-2010-related-file-nesting][1] [1]: http://stackoverflow.com/questions/3046591/visual-studio-2010-related-file-nesting – Mr. TA Jun 04 '12 at 16:24

6 Answers6

5

In my (VisualStudio 2005) system, they are stored in the registry under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Projects\{E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles

For VisualStudio 2008, change the \8.0\ to \9.0\

Note, however, that the GUID in the middle refers to the type of project (VB Console, C# Web, etc) it is. You may have to poke around to find the right one for you.

James Curran
  • 101,701
  • 37
  • 181
  • 258
4

In VS 2008, there is also a project file-level way to do this via the DependentUpon tag. You would edit your project file to look like this:

<Compile Include="SomeTableClass.cs" />
<Compile Include="SomeTableClass.Generated.cs">
    <DependentUpon>SomeTableClass.cs</DependentUpon>
</Compile>
OwenP
  • 24,950
  • 13
  • 65
  • 102
2

In my Windows 7 x64 environment, the registry keys for Visual Studio 2008 Professional are located here:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Projects\{E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles

dansays
  • 2,729
  • 4
  • 22
  • 20
2

In Visual Studio 2012, they are to be found in the HKCU, i.e.:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config\{E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles

Sebastian
  • 6,293
  • 6
  • 34
  • 47
  • sadly I have not managed to use the .ts with .js. It seems it does not work for all extensions this way – Sebastian Nov 04 '13 at 22:19
2

A useful VS plugin has since popped up that takes care of this problem for me: NestIn

TWith2Sugars
  • 3,384
  • 2
  • 26
  • 43
1

By Visual Studio 2022 there is a feature named, "File nesting" which can be toggled from the Solution Explorer toolbar button.

Boggin
  • 3,251
  • 3
  • 33
  • 48