Can I create a file that is next to the .Designer.cs file in Visual Studio?

In Visual Studio, two files are created when you create a new Windows form in your solution (for example, if you create MyForm.cs, MyForm.Designer.cs and MyForm.resx are also created). These two second files are displayed as a subtree in Solution Explorer.

Can I add files to a subtree or group for a Windows Form class?

+7
c # visual-studio-2008
source share
3 answers

Open .csproj in edit mode, find the file you want to be under another, and add a DependentUpon element, for example:

<Compile Include="AlertDialog.xaml.cs"> <DependentUpon>AlertDialog.xaml</DependentUpon> </Compile> 
+14
source share

You need to edit csproj directly. There is a DependentUpon tag that you must add as a child tag of the file you want to place in MyForm.cs.

Example:

 <Compile Include="MyForm.MyCoolSubFile.cs"> <DependentUpon>MyForm.cs</DependentUpon> </Compile> 
+6
source share

Yes, but this is a bit of a hassle - basically you need to manually edit the project file.

Here is an example from the project we are working with Mark Gravell and others:

 <Compile Include="Linq\Extensions\DataProducerExt.cs" /> <Compile Include="Linq\Extensions\DataProducerExt.SingleReturn.cs"> <DependentUpon>DataProducerExt.cs</DependentUpon> </Compile> <Compile Include="Linq\Extensions\DataProducerExt.Grouping.cs"> <DependentUpon>DataProducerExt.cs</DependentUpon> </Compile> <Compile Include="Linq\Extensions\DataProducerExt.Pipeline.cs"> <DependentUpon>DataProducerExt.cs</DependentUpon> </Compile> <Compile Include="Linq\Extensions\DataProducerExt.Conversion.cs"> <DependentUpon>DataProducerExt.cs</DependentUpon> </Compile> <Compile Include="Linq\Extensions\DataProducerExt.Math.cs"> <DependentUpon>DataProducerExt.cs</DependentUpon> </Compile> 

Note the "DependentUpon" element in each of the dependencies. This is displayed appropriately in VS, and DataProducerExt.cs as the parent.

+4
source share

All Articles