views:

33

answers:

2

In Visual Studio 2008/2010 it's possible to place a series of simple .cs code files underneath another .cs file in solution explorer. This behavior is similar to how you see files arranged when adding a WPF UserControl to the solution, where instead a single .cs file can collapse/expand underneath the .xaml file.

How do you make the solution arrange files this way? I've already looked in some of the obvious places, like the file properties pane, the solution and .csproj property pages.

+3  A: 

I'm not sure there is a way to do this through the Visual Studio UI.

You can do it by manually editing the .csproj file. The trick is to add the <DependentUpon> XML tag to the element you want to appear under another. For example

<Compile Include="Settings.Designer.cs">
  <AutoGen>True</AutoGen>
  <DependentUpon>Settings.settings</DependentUpon>
  <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
JaredPar
use vscommands http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf
+3  A: 

You have to edit the .csproj file and add this:

<Compile Include="Form1.Designer.cs">
  <DependentUpon>Form1.cs</DependentUpon>
</Compile>

Or install a plugin like VSCommands in Visual Studio 2010.

Jérémie Bertrand